random normal distributed numbers
13 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (3 件)
Andrei Bobrov
2012 年 7 月 6 日
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 件のコメント
Andreas
2012 年 7 月 6 日
1 件のコメント
AC
2012 年 7 月 6 日
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
2012 年 7 月 6 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!