van@group1.uucp (Van Bagnol) (04/05/91)
I am looking for a C or Fortran function that would generate a pseudorandom variable but with a *normal* distribution instead of uniform distribution. (I.e., return a random value Z with a mean of 0 and a std. dev. of 1.) * Does anyone know of any algorithm(s)? * What are their pros/cons? So far we have thought of using a "Monte Carlo" approach: take a sample of "n" uniformly random numbers between 0 and 1, then get its mean and s.d. and adjust to taste. Is there a faster and/or more elegant way? (BTW, how big should "n" be, 25? 30?) Many thanks in advance. -- Van Bagnol / Group One, Ltd. / (415) 398-7565 / ...!uunet!group1!van "Be cool, have fun." / "Parang lumakad ko sa loob ang panaginip..."
gwyn@smoke.brl.mil (Doug Gwyn) (04/05/91)
In article <1991Apr04.183739.4876@group1.UUCP> van@group1.uucp (Van Bagnol) writes: >I am looking for a C or Fortran function that would generate a >pseudorandom variable but with a *normal* distribution instead >of uniform distribution. Gee, for all questions of this type the first thing you MUST do is to see what Knuth had to say about it in Vol. 2 of The Art of Computer Programming.
henry@zoo.toronto.edu (Henry Spencer) (04/06/91)
In article <15714@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >>I am looking for a C or Fortran function that would generate a >>pseudorandom variable but with a *normal* distribution... > >Gee, for all questions of this type the first thing you MUST do is >to see what Knuth had to say about it in Vol. 2 ... And typically the second thing you do is dig out "Numerical Recipes" and see what it has to say. Random Numbers is chapter 7. -- "The stories one hears about putting up | Henry Spencer @ U of Toronto Zoology SunOS 4.1.1 are all true." -D. Harrison| henry@zoo.toronto.edu utzoo!henry
gsh7w@astsun.astro.Virginia.EDU (Greg Hennessy) (04/06/91)
Henry Spencer writes:
#And typically the second thing you do is dig out "Numerical Recipes"
#and see what it has to say. Random Numbers is chapter 7.
Sci.physics just had a flamewar^h^h^h^h^H^h^h^hdiscussion about
Numerical Recipies. The general conclusion is to take any canned
routine with a grain of salt.
--
-Greg Hennessy, University of Virginia
USPS Mail: Astronomy Department, Charlottesville, VA 22903-2475 USA
Internet: gsh7w@virginia.edu
UUCP: ...!uunet!virginia!gsh7w
henry@zoo.toronto.edu (Henry Spencer) (04/06/91)
In article <1991Apr5.215418.352@murdoch.acc.Virginia.EDU> gsh7w@astsun.astro.Virginia.EDU (Greg Hennessy) writes: >Sci.physics just had a flamewar^h^h^h^h^H^h^h^hdiscussion about >Numerical Recipies. The general conclusion is to take any canned >routine with a grain of salt. Very true, but for those who are not sophisticated enough to analyze a problem in depth, or lack the time for an exhaustive study, the odds are very good that NR's code is better than what they would come up with on their own. -- "The stories one hears about putting up | Henry Spencer @ U of Toronto Zoology SunOS 4.1.1 are all true." -D. Harrison| henry@zoo.toronto.edu utzoo!henry