Random gauss numbers? ( and other distributions of random numbers)

Dear Daniel,

the GNU Scientific Library (GSL) includes pseudo random number generation
methods.
There is a Ruby binding for this library (Ruby-GSL).

Best regards,

Axel

Just remember that the GSL is under the GNU GPL, which makes it
inappropriate for some applications.

-austin

···

On 11/30/05, Nuralanur@aol.com <Nuralanur@aol.com> wrote:

the GNU Scientific Library (GSL) includes pseudo random number generation
methods.
There is a Ruby binding for this library (Ruby-GSL).

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Try this, if you don't need high performance...

def rand_normal_float(mean = 0.0, variance = 1.0)
   # sum 12 random numbers uniformly distributed in [0,1]
   sum = 0.0
   12.times { sum += Kernel.rand }
   # adjust for mean and variance
   (variance.to_f * (sum - 6.0)) + mean.to_f
end

--Steve

···

On Nov 30, 2005, at 1:28 AM, Nuralanur@aol.com wrote:

the GNU Scientific Library (GSL) includes pseudo random number generation
methods.
There is a Ruby binding for this library (Ruby-GSL).

Hi!

Try this, if you don't need high performance...

def rand_normal_float(mean = 0.0, variance = 1.0)
   # sum 12 random numbers uniformly distributed in [0,1]
   sum = 0.0
   12.times { sum += Kernel.rand }
   # adjust for mean and variance
   (variance.to_f * (sum - 6.0)) + mean.to_f
end

My mathematical intuition says that the Gaussian distribution is
achieved as the limit of the above replacing 12 by N (and 6 by N/2)
and then computing the limit for N versus infinity. Without knowing
the quality of the approximation of using 12 in place of infinity the
approximation is of no practical value. Besides that summing up
pseudo-random numbers may decrease their randomness.

Josef 'Jupp' Schugt

···

At Thu, 1 Dec 2005 01:01:39 +0900, Stephen Waits wrote:
--
Diese E-Mail wurde moeglicherweise erst mehrere Stunden nach ihrer
Fertigstellung versendet, um Onlinekosten zu sparen.
This e-mail has possibly been sent several hours after composition
in order to reduce online costs.

Take a look at this website. Shouldn't be hard at all to implement in ruby.

_Kevin

···

-----Original Message-----
From: Josef 'Jupp' SCHUGT [mailto:jupp@gmx.de]
Sent: Monday, December 05, 2005 05:10 PM
To: ruby-talk ML
Subject: Re: Random gauss numbers? ( and other distributions of random
numbers)

Hi!

At Thu, 1 Dec 2005 01:01:39 +0900, Stephen Waits wrote:

Try this, if you don't need high performance...

def rand_normal_float(mean = 0.0, variance = 1.0)
   # sum 12 random numbers uniformly distributed in [0,1]
   sum = 0.0
   12.times { sum += Kernel.rand }
   # adjust for mean and variance
   (variance.to_f * (sum - 6.0)) + mean.to_f end

My mathematical intuition says that the Gaussian distribution is achieved as
the limit of the above replacing 12 by N (and 6 by N/2) and then computing
the limit for N versus infinity. Without knowing the quality of the
approximation of using 12 in place of infinity the approximation is of no
practical value. Besides that summing up pseudo-random numbers may decrease
their randomness.

Josef 'Jupp' Schugt
--
Diese E-Mail wurde moeglicherweise erst mehrere Stunden nach ihrer
Fertigstellung versendet, um Onlinekosten zu sparen.
This e-mail has possibly been sent several hours after composition in order
to reduce online costs.