RosettaCodeData/Task/Statistics-Normal-distribution/Stata/statistics-normal-distribut...

20 lines
579 B
Plaintext

clear all
set obs 100000
gen u=runiform()
gen v=runiform()
gen r=sqrt(-2*log(u))
gen x=r*cos(2*_pi*v)
gen y=r*sin(2*_pi*v)
gen z=rnormal()
sum x y z
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
x | 100,000 .0025861 1.002346 -4.508192 4.164336
y | 100,000 .0017389 1.001586 -4.631144 4.460274
z | 100,000 .005054 .9998861 -5.134265 4.449522
hist x, normal
hist y, normal
hist z, normal
qqplot x z, msize(tiny)