What is some code to generate normally distributed random numbers in ruby?
(Note: I answered my own question, but I’ll wait a few days before accepting to see if anyone has a better answer.)
EDIT:
Searching for this, I looked at all pages on SO resulting from the two searches:
+”normal distribution” ruby
and
+gaussian +random ruby
Python’s random.gauss() and Boost’s normal_distribution both use the Box-Muller transform, so that should be good enough for Ruby too.
The method can be wrapped up in a class that returns the samples one by one.
To the extent possible under law, antonakos has waived all copyright and related or neighboring rights to the
RandomGaussianRuby class. This work is published from: Denmark.