Advertisement
ostyleo

Untitled

Dec 15th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.24 KB | None | 0 0
  1. function M = Marsaglia(m,n)
  2.     V1 = -1 + (1 - -1).*rand(m,n);
  3.     V2 = -1 + (1 - -1).*rand(m,n);
  4.     S = V1*V1 + V2*V2;
  5.     Z1 = V1 * sqrt((-2 * log(S))/S);
  6.     Z2 = V2 * sqrt((-2 * log(S))/S);
  7.     Z3 = [Z1;Z2];
  8.     M = reshape(Z3,[],1);
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement