random normal distributed numbers
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Andrei Bobrov
el 6 de Jul. de 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 comentarios
Andreas
el 6 de Jul. de 2012
1 comentario
AC
el 6 de Jul. de 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
el 6 de Jul. de 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!