mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx::math::randomT< typeT, _ranengT, _randistT > Class Template Reference

template<class typeT, class _ranengT, class _randistT>
class mx::math::randomT< typeT, _ranengT, _randistT >

A random number type, which functions like any other arithmetic type.

Combines a random engine, and a random distribution. Using the type conversion operator randomT returns the next random deviate whenever it is referenced.

Example:

//This can also be done using the alias definition mx::math::normDistT.
norm_distd.seed(); //
double d1 = norm_distd; //get a normally distributed value
double d2 = norm_distd; //get the next normally distributed value
randomT(bool doSeed=true)
Constructor.
Definition randomT.hpp:72
void seed(typename ranengT::result_type seedval)
Set the seed of the random engine.
Definition randomT.hpp:96

Definition at line 58 of file randomT.hpp.

#include <math/randomT.hpp>

Public Types

typedef _randistT randistT
 Typedef for the distribution type.
typedef _ranengT ranengT
 Typedef for the engine type.

Public Member Functions

 randomT (bool doSeed=true)
 Constructor.
 operator typeT ()
 The conversion operator, returns the next value in the sequence, according to the distribution.
void seed (typename ranengT::result_type seedval)
 Set the seed of the random engine.
void seed ()
 Seed the random engine with a good value.

Public Attributes

_randistT distribution
 The random distribution.
ranengT engine
 The random engine.

Member Typedef Documentation

◆ randistT

template<class typeT, class _ranengT, class _randistT>
typedef _randistT mx::math::randomT< typeT, _ranengT, _randistT >::randistT

Typedef for the distribution type.

Definition at line 63 of file randomT.hpp.

◆ ranengT

template<class typeT, class _ranengT, class _randistT>
typedef _ranengT mx::math::randomT< typeT, _ranengT, _randistT >::ranengT

Typedef for the engine type.

Definition at line 66 of file randomT.hpp.

Constructor & Destructor Documentation

◆ randomT()

template<class typeT, class _ranengT, class _randistT>
mx::math::randomT< typeT, _ranengT, _randistT >::randomT ( bool doSeed = true)
inline

Constructor.

By default this calls the seed method, which will use /dev/random to seed the generator on linux, and time(0) on other systems. Set to false to suppress seeding, and/or set a seed with seed(x).

Parameters
[in]doSeed[optional] if true then the seed method is called upon construction.

Definition at line 72 of file randomT.hpp.

Member Function Documentation

◆ operator typeT()

template<class typeT, class _ranengT, class _randistT>
mx::math::randomT< typeT, _ranengT, _randistT >::operator typeT ( )
inline

The conversion operator, returns the next value in the sequence, according to the distribution.

Definition at line 87 of file randomT.hpp.

◆ seed() [1/2]

template<class typeT, class _ranengT, class _randistT>
void mx::math::randomT< typeT, _ranengT, _randistT >::seed ( )
inline

Seed the random engine with a good value.

Calls mx::math::randomSeed to get the value. On Linux this uses /dev/urandom. On other systems, this uses time(0).

Definition at line 105 of file randomT.hpp.

Referenced by mx::math::randomT< realT, std::mt19937_64, std::normal_distribution< realT > >::randomT(), and mx::math::randomT< realT, std::mt19937_64, std::normal_distribution< realT > >::seed().

◆ seed() [2/2]

template<class typeT, class _ranengT, class _randistT>
void mx::math::randomT< typeT, _ranengT, _randistT >::seed ( typename ranengT::result_type seedval)
inline

Set the seed of the random engine.

Calls the engines seed member function.

Parameters
[in]seedvalthe argument to pass to ranengT::seed()

Definition at line 96 of file randomT.hpp.

Referenced by mx::AO::influenceFunctionsGaussian(), mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::intensityPSD(), mx::AO::analysis::speckleAmpPSD(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

Member Data Documentation

◆ distribution

template<class typeT, class _ranengT, class _randistT>
_randistT mx::math::randomT< typeT, _ranengT, _randistT >::distribution

The random distribution.

Definition at line 81 of file randomT.hpp.

Referenced by mx::math::randomT< int, std::mt19937_64, std::poisson_distribution< int > >::operator int().

◆ engine

template<class typeT, class _ranengT, class _randistT>
ranengT mx::math::randomT< typeT, _ranengT, _randistT >::engine

The random engine.

Definition at line 84 of file randomT.hpp.


The documentation for this class was generated from the following file: