Random numbers: Difference between revisions
Content added Content deleted
(→{{header|PARI/GP}}: one programming error corrected, visual check of improve of distribution. No further tests.) |
|||
Line 1,878: | Line 1,878: | ||
<lang parigp>rnormal()={ |
<lang parigp>rnormal()={ |
||
my(pr=32*ceil(default(realprecision)*log(10)/log(4294967296)),u1=random(2^pr)*1.>>pr,u2=random(2^pr)*1.>>pr); |
my(pr=32*ceil(default(realprecision)*log(10)/log(4294967296)),u1=random(2^pr)*1.>>pr,u2=random(2^pr)*1.>>pr); |
||
sqrt(-2*log(u1))*cos(2*Pi* |
sqrt(-2*log(u1))*cos(2*Pi*u2) \\ in previous version "u1" instead of "u2" was used --> has given crap distribution |
||
\\ Could easily be extended with a second normal at very little cost. |
\\ Could easily be extended with a second normal at very little cost. |
||
}; |
}; |