rand(1) returns one pseudo random number between 0 and 1 correct? (I don't know matlab myself but I know what you can do with the random number)

Use the Box-Muller transform.

This transform says is standard deviation σ.


mu = 5; //enter the mean you want or need
sigma = 3; //enter the standard deviation you want or need

u1 = rand(1);
u2 = rand(2);

z1 = sqrt(-2 * Log[u1]) * Sin[2 *pi * u2];
z2 = sqrt(-2 * Log[u1]) * Cos[2 * pi * u2];

x1 = mu + z1 * sigma;
x2 = mu + z2 * sigma;

 

http://www.taygeta.com/random/gaussian.html

 

相关文章: