/* Compare Box-Muller and Mox-Buller transformations */ data a b ; seed1 = 1917515 ; seed2 = 5151917 ; do i = 1 to 10000 ; u = ranuni(seed1) ; v = ranuni(seed2) ; /* this is Box-Muller tfm */ x = sin(6.28318*u)*sqrt(-2*log(v)) ; y = cos(6.28318*u)*sqrt(-2*log(v)) ; output a ; /* this is Mox-Buller */ x = sin(6.28318*u)*sqrt(-2*log(v)) ; y = cos(6.28318*v)*sqrt(-2*log(u)) ; output b ; end ; proc univariate data=a plot normal ; var x y ; title 'Usual Box-Muller' ; proc corr cov data=a ; var x y ; proc univariate data=b plot normal ; var x y ; title 'Goofy Mox-Buller transformation' ; proc corr cov data=b ; var x y ; proc gplot data=a ; plot y*x ; title 'Usual Box-Muller' ; proc gplot data=b ; plot y*x ; title 'Goofy Mox-Buller transformation' ; run ;