Random Gaussian Number Generator

From Second Life Wiki
Revision as of 11:10, 26 December 2010 by Vlad Davidson (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<lsl> float randGauss(float mean=0.,float stdev=1.){ float V1,V2,S; do{ V1=2*llFrand(1.)-1; V2=2*llFrand(1.)-1; S=V1*V1+V2*V2; }while (S>=1); return mean+stdev*V1*llSqrt(-2*(llLog(S)/S)); } </lsl>