generating a list with normal distribution

Hi Guys,I need to generate a list with “bell curve” normal distribution. Ihad a go at doing this in q today. I used the polar method describedhere: http://en.wikipedia.org/wiki/Normal\_distributionq)nd0:{w:where 1>s::sum each 0N 2#xexp[UV::1-(x*2)?2.;2];UV[w]*sqrtneg 2*(log s[w])%s[w]}q)nd:{x#raze nd0 $[x<100;50;“i”$x*2%5]}q)nd 42.195277 -0.3582161 -1.52565 -0.4338306Ta,Jack.

http://kx.com/q/stat.q

charset=“iso-8859-1”

X-Mailer: Microsoft Outlook 14.0
Thread-index: AQKoPbBIuT41kA4o6kAa759Qdn0ftJZe6asg
Content-language: de

Do you mean this method?
http://en.wikipedia.org/wiki/Marsaglia\_polar\_method

bm:{ r : last {p: -1 + (2?2.0); xx::p 0; sum p*p}[1<;2];
:xx * sqrt ((-2.0 * log r) % r) }

Stolen from http://www.rendezvouswithdestiny.net/finance/finance.html .

Since bm uses scan the implementation in stat.q is faster and more
eleganter.

Thx,
Kim

-----Urspr=FCngliche Nachricht-----
Von: personal-kdbplus@googlegroups.com
[mailto:personal-kdbplus@googlegroups.com] Im Auftrag von Jack Andrews
Gesendet: Dienstag, 11. Dezember 2012 13:29
An: Kdb+ Personal Developers
Betreff: [personal kdb+] generating a list with normal distribution

Hi Guys,

I need to generate a list with “bell curve” normal distribution. I had =
a go
at doing this in q today. I used the polar method described
here: http://en.wikipedia.org/wiki/Normal\_distribution

q)nd0:{w:where 1>s::sum each 0N 2#xexp[UV::1-(x*2)?2.;2];UV[w]*sqrt
neg 2*(log s[w])%s[w]}
q)nd:{x#raze nd0 $[x<100;50;“i”$x*2%5]}
q)nd 4
2.195277 -0.3582161 -1.52565 -0.4338306

Ta,

Jack.


You received this message because you are subscribed to the Google =
Groups
“Kdb+ Personal Developers” group.
To post to this group, send email to personal-kdbplus@googlegroups.com.
To unsubscribe from this group, send email to
personal-kdbplus+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/personal-kdbplus?hl=3Den.