random normal distributed numbers
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
i have a quite simple question(at least i think so^^) but cant find the answer.
i want to produce numbers which are normal distributed. the numbers have to be in a range between a and b, where are 3 sigma of values(99,73%) have to be in that range. at the moment i have this:
a=1.4; %%%minimal Value
b=1.6; %%%maximal Value
c=(a+b)/2; %%%average
sigma=1;
R=normrnd(c,sigma,1,1000);
but i dont know how i can tell matlab that i want the value in the range of a to b? and that this range schould be contains 3sigma of the values.. maybe i have to use an other function? thanks for any help ;)
0 Kommentare
Antworten (3)
Andrei Bobrov
am 6 Jul. 2012
BUT this is NOT normal distribution
k = randn(100,1);
a=1.4;
b=1.6;
m = min(k);
out = (k - m)*(b - a)/(max(k)-m) + a;
0 Kommentare
Andreas
am 6 Jul. 2012
1 Kommentar
AC
am 6 Jul. 2012
Is it ok if you get less than 1000 numbers in the end? Because you could just truncate your vector R up there. But you would end up with some 997 values in the end if your number is correct. (Actually I'm guessing you thought about that already, so I'm not sure...)
Walter Roberson
am 6 Jul. 2012
Normal distribution are defined to have infinite tails. If you have a constrained value range, then it is not normal distribution.
If you want to construct a normal distribution such that 3 sigma is between a and b, but values outside that range are still possible, then that is a different matter.
Remember, if 99.73% is within the range a to b, then if you select 1000 random values, then on average 2.7 of the results will be outside a to b
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!