Sampling random numbers from normal distribution with given probability (Matlab)
As seen in the code below, I am currently generating random numbers from a Normal Distribution and am selecting the ones within the -3*sigma and 3*sigma interval.
However, I now want to generate numbers such that there is a higher probability that I select numbers from outside the -3*sigma and 3*sigma interval. Eg a number from [-4*sigma -3*sigma) should have 35% probability of being chosen and same for [3*sigma 4*sigma).
Basically, I'll be calling this function several times and am wondering if there is a way for me to select a higher proportion of random numbers from the "tails" of the normal distribution, without actually altering the shape of the normal distribution.
I have been told to use a "Rejection sampling algorithm" or the "Metropolis-Hastings algorithm" for this problem. I am struggling to understand how to implement either. Could someone provide a slight push in the right direction? I'm using
N = pdf('Normal',136e9-(3*9.067e9):1e8:136e9+(3*9.067e9),136e9,9.067e9)
to first generate a pdf
to draw from. However, I am then unsure which I should take as my "target distribution" and which I should take as the "proposed distribution".
function [new_E11, new_E22] = elasticmodulusrng()
new_E11 = normrnd(136e9,9.067e9,[1 1]);
new_E22 = normrnd(8.9e9,2.373e9,[1 1]);
while new_E11<=-3*9.067e9 && new_E11>=3*9.067e9
new_E11 = normrnd(136e9,9.067e9,[1 1]);
end
while new_E11<=-3*2.373e9 && new_E11>=3*2.373e9
new_E22 = normrnd(8.9e9,2.373e9,[1 1]);
end
Thanks
链接地址: http://www.djcxy.com/p/24822.html上一篇: 如何查找R中的数字是否连续?