How to get just positive numbers which follows normal distribution?
24 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello all,
I am generating random samples of Weibull distribution. The shape and scale parameter for this Weibull distribution are itself normally distributed. In particular, the shape parameter has mean of 1 and standard deviation of 5. So I first generate sample pairs of shape and scale parameters and then I generate samples of Weibull distribution corresponding to each pair. So I am interested in knowing that how to ensure that output of normrnd function will always be positive especially when mean is 1 and standard deviation is 5? I mean how to get normally distributed samples which will always be positive. The reason I need this is because these samples are for Shape parameters. And shape parameter of Weibull distribution is always positive, else wblrnd function gives error. Any guidance in this regard will be highly appreciated, Thanks in advance,
Nikhil
0 Commenti
Risposta accettata
SK
il 11 Ott 2014
There is no way to prevent a normally distributed variable from taking on negative values (otherwise you can't call it normally distributed, no?). You could either approximate a normal distribution by making the std deviation much smaller than the mean (at least three time smaller) and then rejecting any negative values from normrnd. Ex:
x = 0;
while (x < 0)
x = normrnd(1, 1/3);
end
Alternatively use a one sided normal distribution:
x = abs(normrnd(0, s));
where you choose s in such a way that the mean of the one sided distribution equals 1.
Another alternative is to use an exponential distribution, which is always positive and tapers off to zero - but more slowly than the normal.
x = -log(1 - rand); % mean == 1
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!