Skip to content

Instantly share code, notes, and snippets.

@Prunus1350
Created January 14, 2015 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Prunus1350/6b6aa014a73c9d7bbee2 to your computer and use it in GitHub Desktop.
Save Prunus1350/6b6aa014a73c9d7bbee2 to your computer and use it in GitHub Desktop.
Box-Muller法によるガウス乱数の生成
data rand_normal;
do i = 1 to 1000;
y1 = sqrt(-2 * log(rand("uniform"))) * cos(2 * constant("pi") * rand("uniform"));
y2 = sqrt(-2 * log(rand("uniform"))) * sin(2 * constant("pi") * rand("uniform"));
output;
end;
run;
proc sgplot data = rand_normal;
histogram y1;
run;
proc univariate data = rand_normal normal;
var y1;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment