shaq
Full Member level 5
box muller matlab
Hello everyone,
We know that Box-Muller method is to transfer uniform distribution to normal distribution.
For more information, pls contact this site:
https://mathworld.wolfram.com/Box-MullerTransformation.html
Now, I have a little problem.
I want to plot the result of using Box-Muller method in Matlab by using surf( ).
I have a short code about Box-Muller method, but the result is histogram figure.
%%%%%%Code Starts%%%%%%%%%%%
for i=1:10000
u1=rand(1);
u2=rand(1);
x1=sqrt(-2*log(u1))*cos(2*pi*u2);
x2=sqrt(-2*log(u2))*sin(2*pi*u1);
rv1(i,1)=x1;
rv2(i,1)=x2;
end
rv=[rv1;rv2];
x = -3:0.1:3;
hist(rv,x)
%%%%%%Code Ends%%%%%%%%%%%%
Can anyone help me to modify this code to display 3D figure?
Hello everyone,
We know that Box-Muller method is to transfer uniform distribution to normal distribution.
For more information, pls contact this site:
https://mathworld.wolfram.com/Box-MullerTransformation.html
Now, I have a little problem.
I want to plot the result of using Box-Muller method in Matlab by using surf( ).
I have a short code about Box-Muller method, but the result is histogram figure.
%%%%%%Code Starts%%%%%%%%%%%
for i=1:10000
u1=rand(1);
u2=rand(1);
x1=sqrt(-2*log(u1))*cos(2*pi*u2);
x2=sqrt(-2*log(u2))*sin(2*pi*u1);
rv1(i,1)=x1;
rv2(i,1)=x2;
end
rv=[rv1;rv2];
x = -3:0.1:3;
hist(rv,x)
%%%%%%Code Ends%%%%%%%%%%%%
Can anyone help me to modify this code to display 3D figure?