help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: Fwd: [Help-gsl] random number distributions

 From: John D Lamb Subject: Re: Fwd: [Help-gsl] random number distributions Date: Thu, 18 May 2006 13:48:47 +0100 User-agent: Mozilla Thunderbird 1.0.8 (X11/20060411)

```John Gehman wrote:
```
if you like check out R.W. Hamming "Numerical Methods for Scientists and Engineers", -- you can generate a gaussian random number by summing 12 uniform random numbers and subtract 6.0. There's a subtle caveat which explains that this isn't perfect, but in most cases is actually closer to what you want than a perfectly gaussian random number (i.e. do you ever really want random number which has probability of 137*sigma, even if strictly speaking it's bound to happen sooner or later in a true gaussian distribution?)
```
Begin forwarded message:

```
I wish to use _in same program_ a random number generator which provides uniformly distributed random numbers _and_ a function which returns a Gaussian random variate.
```Theses functions requires two calls to a random number generator.
```
So, I'm wondering whether I have to set one or two random number generator ?
```Thanks in advance,
Regards,
```
There is nothing to stop you using two random number generators, though you probably only need one. If you use two random number generators with the same seed and call them equally often then the results will be strongly correlated. If you use just one they will be nearly uncorrelated. So I use one unless there's a good reason to do otherwise.
```
```
gsl_ran_gaussian is more accurate and often faster than summing random numbers because it uses an exact method. Speed will depend on the speed of the random number generators, whcih depends on the quality. Typically the better quality random number generators are slower. gsl_ran_gaussian uses (I think) Box-Müller, which requires on average one call to the random number generator per gaussian variate. The ziggurat method (on the GSL web pages), maybe in the latest gsl release is faster than Box-Müller for any gsl random number generator.
```

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]