[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best random number generator algorithms to use with `gsl_ran_gaussia
From: |
Jean-François Caron |
Subject: |
Re: Best random number generator algorithms to use with `gsl_ran_gaussian` |
Date: |
Fri, 10 Dec 2021 13:43:57 -0800 |
Based on the descriptions in the docs, and since you don't care about speed of
generation, I would recommend ranlxs2 for single-precision and ranlxd2 for
double-precision floats.
Mersenne Twister is a good balance of speed and quality of the randomness (and
large period), while ranlxd2 makes no compromises for speed.
Jean-François
> On Dec 10, 2021, at 13:16, Vicent Giner Bosch <vigibos@eio.upv.es> wrote:
>
> [CAUTION: Non-UBC Email]
>
> I am using GSL's `gsl_ran_gaussian` (actually, the version with unit
> variance `gsl_ran_ugaussian`) to generate pseudorandom values of a
> normal random variable.
>
> According to the documentation, one of the arguments of the function
> `gsl_ran_gaussian` is a pseudorandom number generator `r` (an instance
> of the `gsl_rng` struct) that will be intialised before calling
> `gsl_ran_gaussian` for the first time.
>
> I was planning to use MT19937 (`gsl_rng_mt19937`) or one of the
> RANLUX-like ones (`ranlxs0`, for instance) as the algorithm to be used
> by `r`, but I am not sure. There are plenty of possible algorithms to
> choose from (see
> https://www.gnu.org/software/gsl/doc/html/rng.html#random-number-generator-algorithms).
>
> I am not looking for how fast the algorithm may be. I am rather much
> more interested in generating pseudorandom values from a Gaussian
> distribution with the best quality from a mathematical standpoint,
> meaning that they seem as 'random' as possible.
>
> So, according to your experience, which is a good pseudorandom number
> algorithm to be used when sampling from a Gaussian distribution.
>
> NOTE: In case it matters, those Gaussian observations will not be
> combined in any way after being generated ---I mean, I am neither
> thinking about adding or subtracting them nor creating n-tuples of
> them, etc.
>
> I look forward to your answers,
>
>
> --
> vicent
>
> @vginer_upv
> vigibos.webs.upv.es
>