Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
sci.math.*
»
sci.stat.math
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
normal distribution generator in C
Replies:
2
Last Post:
Jul 17, 1996 10:29 PM




normal distribution generator in C
Posted:
Jul 11, 1996 7:24 PM


I use the following routine to make a pseudorandom number with a normal distribution:
double nrml() /* a normal random number in range 1 to 1 i.e. N(0,1) */ { double r,u,v; do { do {u = rnmu();} while (u == 0); v = rnmu(); v = 1.7156*(v.5); r = v/u; }while (r*r > 4.00*log(u)); return r; }
where rnmu() delivers a pseudorandom number with a uniform distribution.
At the moment it is adequate however if someone could point me to a better one (preferably in C) I'd appreciate it. I also welcome comments on how to improve this one; rather inefficient.
Mike whitbeck1@llnl.gov



