Random Number Generators

Class providing pseudo-random number generators—algorithms that produce sequences of numbers with the statistical properties of true randomness. Methods return uniform deviates on \([0,1)\), Gaussian deviates, and raw integer samples, with support for seeding and independent sequences per MPI process and OpenMP thread. Random number generators are used throughout Galacticus for Monte Carlo sampling, stochastic merger tree construction, posterior sampling simulations, and generating scatter in model predictions.

Default implementation: randomNumberGeneratorGSL

Methods

mpiIndependentlogical

Return true if this random number generator produces independent sequences per MPI process (when using the same seed and offsetting is requested).

openMPIndependentlogical

Return true if this random number generator produces independent sequences per OpenMP thread (when using the same seed and offsetting is requested).

rangeMinimuminteger(c_long)

Return the smallest integer in the range for this generator.

rangeMaximuminteger(c_long)

Return the largest integer in the range for this generator.

sampleinteger(c_long)

Return a random integer. If the optional argument n is supplied the random integer will lie in the range 0 to n-1 inclusive (with all integers being equally likely). Otherwise, the integer will be drawn from the full range provided by the generator.

  • integer(c_long), intent(in ), optional :: n

uniformSampledouble precision

Return a random number drawn from a uniform distribution on [0,1).

poissonSampleinteger

Return a random number drawn from a Poisson distribution with the given mean.

  • double precision, intent(in ) :: mean

standardNormalSampledouble precision

Return a random number drawn from a standard normal distribution.

seedSetvoid

Reset the seed for this random number generator.

  • integer(c_long), intent(in ) :: seed

  • logical , intent(in ) :: offset

seedinteger(c_long)

Return the seed for this random number generator.

randomNumberGeneratorGSL

A random number generator class which utilizes the GSL random number generators.

(Default implementation)

Parameters

  • [seed] (default 219_c_long) — A seed value for the random number generator.

  • [ompThreadOffset] (default .false.) — If true, offset the seed by the OpenMP thread number.

  • [mpiRankOffset] (default .false.) — If true, offset the seed by the MPI process rank.