random number generator of normal distribution in 2D
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Bjorn Gustavsson
2011-5-27
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 个评论
Tom Lane
2011-5-29
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!