Jump to content

Statistics/Normal distribution: Difference between revisions

m
Line 2,694:
Pairs of normal numbers are generated from pairs of uniform numbers using the [https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform Box-Muller method]. A normal density is added to the histogram for comparison. See '''[http://www.stata.com/help.cgi?histogram histogram]''' in Stata help. A [https://en.wikipedia.org/wiki/Q%E2%80%93Q_plot Q-Q plot] is also drawn.
 
<lang stata>. 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()
. summarizesum x y z
 
Variable | Obs Mean Std. Dev. Min Max
Line 2,709:
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)</lang>
 
=={{header|Tcl}}==
1,336

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.