random number generator of normal distribution in 2D
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, does some of you know if is availiable in Matlab a function that generates random numbers from the 2D normal distribution with mean parameter mu and standard deviation parameter sigma provided in the two dimensions? And also the function to get the Gaussian curve corresponding. Something equivalent to: x = normrnd(mean,sigma,npoint); y = gaussmf(x,[sigma mean]); but in 2D.
Many thanks
Camilla
0 comentarios
Respuestas (2)
Bjorn Gustavsson
el 27 de Mayo de 2011
Maybe something like this for the 2-D random points scattered around r0 with a 2-D normal distribution with major and minor widths of sigma1 and 2 rotated phi radians.
r(1,:) = sigma1*randn([nx*ny,1]); r(2,:) = sigma2*randn([nx*ny,1]);
rotM = [cos(phi) -sin(phi);sin(phi) cos(phi)]; r = rotM*r; r0 = [x0,y0];
r(1,:) = r(1,:) + r0(1); r(2,:) = r(2,:) + r0(2);
HTH, Bjoern
0 comentarios
Tom Lane
el 29 de Mayo de 2011
Camilla, if you have normrnd then you must have the Statistics Toolbox. In that case check out the mvnrnd function for random number generation, and mvnpdf for the density function.
-- Tom
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!