29#ifndef LSST_AFW_MATH_RANDOM_H
30#define LSST_AFW_MATH_RANDOM_H
34#include "gsl/gsl_rng.h"
233 double flat(
double const a,
double const b);
249 double chisq(
double const nu);
256 double poisson(
double const mu);
265 static char const *
const _algorithmEnvVarName;
266 static char const *
const _seedEnvVarName;
292template <
typename ImageT>
301template <
typename ImageT>
311template <
typename ImageT>
322template <
typename ImageT>
331template <
typename ImageT>
341template <
typename ImageT>
351template <
typename ImageT>
A class that can be used to generate sequences of random numbers according to a number of different a...
Random(Algorithm algorithm=MT19937, unsigned long seed=1)
Creates a random number generator that uses the given algorithm to produce random numbers,...
Random(Random &&)=default
Algorithm
Identifiers for the list of supported algorithms.
@ MT19937
The MT19937 "Mersenne Twister" generator of Makoto Matsumoto and Takuji Nishimura.
@ TAUS
A maximally equidistributed combined Tausworthe generator by L'Ecuyer.
@ RANLUX
Original version of the RANLUX algorithm, 24-bit output.
@ RANLXS2
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 2 (stronges...
@ RANLXD1
Double precision (48-bit) output using the RANLXS algorithm, luxury level 1 (weakest).
@ NUM_ALGORITHMS
Number of supported algorithms.
@ MRG
Fifth-order multiple recursive generator by L'Ecuyer, Blouin, and Coutre.
@ GFSR4
A fifth-order multiple recursive generator by L'Ecuyer, Blouin, and Coutre.
@ RANLXS1
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 1 (stronger...
@ RANLXD2
Double precision (48-bit) output using the RANLXS algorithm, luxury level 2 (strongest).
@ RANLXS0
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 0 (weakest)
@ CMRG
Combined multiple recursive generator by L'Ecuyer.
@ TAUS2
A maximally equidistributed combined Tausworthe generator by L'Ecuyer with improved seeding relative ...
@ RANLUX389
Original version of the RANLUX algorithm, 24-bit output (all bits are decorrelated).
double uniformPos()
Returns a uniformly distributed random double precision floating point number from the generator.
double chisq(double const nu)
Returns a random variate from the chi-squared distribution with nu degrees of freedom.
Random deepCopy() const
Creates a deep copy of this random number generator.
static std::vector< std::string > const & getAlgorithmNames()
double poisson(double const mu)
Returns a random variate from the poisson distribution with mean mu.
Algorithm getAlgorithm() const
std::string getAlgorithmName() const
Random & operator=(Random const &)=default
unsigned long getSeed() const
double gaussian()
Returns a gaussian random variate with mean 0 and standard deviation 1
void setState(State const &state)
Random(Random const &)=default
std::size_t getStateSize() const
double uniform()
Returns a uniformly distributed random double precision floating point number from the generator.
unsigned long uniformInt(unsigned long n)
Returns a uniformly distributed random integer from 0 to n-1.
double flat(double const a, double const b)
Returns a random variate from the flat (uniform) distribution on [a, b).
Random & operator=(Random &&)=default
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
void randomUniformImage(ImageT *image, Random &rand)
Set image to random numbers uniformly distributed in the range [0, 1)
void randomPoissonImage(ImageT *image, Random &rand, double const mu)
Set image to random numbers with a Poisson distribution with mean mu (n.b.
void randomGaussianImage(ImageT *image, Random &rand)
Set image to random numbers with a gaussian N(0, 1) distribution.
void randomUniformPosImage(ImageT *image, Random &rand)
Set image to random numbers uniformly distributed in the range (0, 1)
void randomFlatImage(ImageT *image, Random &rand, double const a, double const b)
Set image to random numbers uniformly distributed in the range [a, b)
void randomChisqImage(ImageT *image, Random &rand, double const nu)
Set image to random numbers with a chi^2_{nu} distribution.
void randomUniformIntImage(ImageT *image, Random &rand, unsigned long n)
Set image to random integers uniformly distributed in the range 0 ... n - 1.
A base class for image defects.