Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function M = Marsaglia(m,n)
- V1 = -1 + (1 - -1).*rand(m,n);
- V2 = -1 + (1 - -1).*rand(m,n);
- S = V1*V1 + V2*V2;
- Z1 = V1 * sqrt((-2 * log(S))/S);
- Z2 = V2 * sqrt((-2 * log(S))/S);
- Z3 = [Z1;Z2];
- M = reshape(Z3,[],1);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement