32 #ifndef LSST_AFW_MATH_RANDOM_H
33 #define LSST_AFW_MATH_RANDOM_H
37 #include "gsl/gsl_rng.h"
43 namespace lsst {
namespace afw {
namespace math {
99 explicit Random(std::string
const & algorithm,
unsigned long seed = 1);
134 double flat(
double const a,
double const b);
136 double chisq(
double const nu);
137 double poisson(
double const nu);
140 std::shared_ptr< ::gsl_rng>
_rng;
157 template<
typename ImageT>
160 template<
typename ImageT>
163 template<
typename ImageT>
166 template<
typename ImageT>
169 template<
typename ImageT>
172 template<
typename ImageT>
175 template<
typename ImageT>
181 #endif // LSST_AFW_MATH_RANDOM_H
void randomUniformImage(ImageT *image, Random &rand)
Set image to random numbers uniformly distributed in the range [0, 1)
std::shared_ptr< Policy > Ptr
std::string State
Accessors for the opaque state of the random number generator.
Random(Algorithm algorithm=MT19937, unsigned long seed=1)
Creates a random number generator that uses the given algorithm to produce random numbers...
double poisson(double const nu)
Returns a random variate from the poisson distribution with mean mu.
Include files required for standard LSST Exception handling.
Double precision (48-bit) output using the RANLXS algorithm, luxury level 2 (strongest).
unsigned long uniformInt(unsigned long n)
Returns a uniformly distributed random integer from 0 to n-1.
unsigned long getSeed() const
static char const *const _seedEnvVarName
void randomFlatImage(ImageT *image, Random &rand, double const a, double const b)
Set image to random numbers uniformly distributed in the range [a, b)
table::Key< table::Array< Kernel::Pixel > > image
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 0 (weakest)...
std::size_t getStateSize() const
Accessors for the opaque state of the random number generator.
metadata import lsst afw display as afwDisplay n
Fifth-order multiple recursive generator by L'Ecuyer, Blouin, and Coutre.
void randomUniformPosImage(ImageT *image, Random &rand)
Set image to random numbers uniformly distributed in the range (0, 1)
Number of supported algorithms.
static char const *const _algorithmEnvVarName
void setState(State const &state)
Accessors for the opaque state of the random number generator.
Original version of the RANLUX algorithm, 24-bit output (all bits are decorrelated).
void randomChisqImage(ImageT *image, Random &rand, double const nu)
Set image to random numbers with a chi^2_{nu} distribution.
Algorithm getAlgorithm() const
void randomGaussianImage(ImageT *image, Random &rand)
Set image to random numbers with a gaussian N(0, 1) distribution.
double chisq(double const nu)
Returns a random variate from the chi-squared distribution with nu degrees of freedom.
std::string getAlgorithmName() const
double flat(double const a, double const b)
Returns a random variate from the flat (uniform) distribution on [a, b).
static char const *const _algorithmNames[NUM_ALGORITHMS]
std::shared_ptr< ::gsl_rng > _rng
double gaussian()
Returns a gaussian random variate with mean 0 and standard deviation 1.
double uniformPos()
Returns a uniformly distributed random double precision floating point number from the generator...
Algorithm
Identifiers for the list of supported algorithms.
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 1 (stronger...
Combined multiple recursive generator by L'Ecuyer.
void randomUniformIntImage(ImageT *image, Random &rand, unsigned long n)
Set image to random integers uniformly distributed in the range 0 ...
void randomPoissonImage(ImageT *image, Random &rand, double const mu)
Set image to random numbers with a Poisson distribution with mean mu (n.b.
A fifth-order multiple recursive generator by L'Ecuyer, Blouin, and Coutre.
afw::table::Key< double > b
Original version of the RANLUX algorithm, 24-bit output.
A maximally equidistributed combined Tausworthe generator by L'Ecuyer with improved seeding relative ...
Random deepCopy() const
Creates a deep copy of this random number generator.
Second-generation version of the RANLUX algorithm of Lüscher, 24-bit output, luxury level 2 (stronges...
double uniform()
Returns a uniformly distributed random double precision floating point number from the generator...
A class that can be used to generate sequences of random numbers according to a number of different a...
State getState() const
Accessors for the opaque state of the random number generator.
::gsl_rng_type const *const _gslRngTypes[NUM_ALGORITHMS]
A maximally equidistributed combined Tausworthe generator by L'Ecuyer.
The MT19937 "Mersenne Twister" generator of Makoto Matsumoto and Takuji Nishimura.
static std::vector< std::string > const & getAlgorithmNames()
Double precision (48-bit) output using the RANLXS algorithm, luxury level 1 (weakest).