prrng 1.12.1
Loading...
Searching...
No Matches
prrng::pcg32_index Class Reference

Overload of prrng::pcg32() that keeps track of the current index of the generator in the sequence. More...

#include <prrng.h>

Inheritance diagram for prrng::pcg32_index:
prrng::pcg32 prrng::GeneratorBase< pcg32 >

Public Member Functions

template<typename T = uint64_t, typename S = uint64_t>
 pcg32_index (T initstate=0x853c49e6748fea9bULL, S initseq=0xda3e39cb94b95bdbULL, bool delta=false)
 
uint64_t state_at (ptrdiff_t index)
 State at a specific index of the sequence.
 
void jump_to (ptrdiff_t index)
 Move to a certain index.
 
void drawn (ptrdiff_t n)
 Update the generator index with the number of items you have drawn.
 
void set_delta (bool delta)
 Signal if the generator is uniquely used to draw a delta distribution.
 
ptrdiff_t index () const
 Get the generator index.
 
void set_index (ptrdiff_t index)
 Overwrite the generator index.
 
- Public Member Functions inherited from prrng::pcg32
template<typename T = uint64_t, typename S = uint64_t>
 pcg32 (T initstate=0x853c49e6748fea9bULL, S initseq=0xda3e39cb94b95bdbULL)
 Constructor.
 
void seed (uint64_t initstate=0x853c49e6748fea9bULL, uint64_t initseq=0xda3e39cb94b95bdbULL)
 Seed the generator (constructor alias).
 
uint32_t operator() ()
 Draw new random number (uniformly distributed, 0 <= r <= max(uint32_t)).
 
uint32_t next_uint32 ()
 Draw new random number (uniformly distributed, 0 <= r <= max(uint32_t)).
 
uint32_t next_uint32 (uint32_t bound)
 Draw new random number (uniformly distributed, 0 <= r <= bound).
 
float next_float ()
 Generate a single precision floating point value on the interval [0, 1).
 
double next_double ()
 Generate a double precision floating point value on the interval [0, 1).
 
double next_positive_double ()
 Generate a double precision floating point value on the interval (0, 1).
 
uint64_t state () const
 The current "state" of the generator.
 
template<typename R >
state ()
 The current "state" of the generator.
 
uint64_t initstate () const
 The state initiator that was used upon construction.
 
template<typename R >
initstate () const
 The state initiator that was used upon construction.
 
uint64_t initseq () const
 The sequence initiator that was used upon construction.
 
template<typename R >
initseq () const
 The sequence initiator that was used upon construction.
 
template<typename T >
void restore (T state)
 Restore a given state in the sequence.
 
int64_t operator- (const pcg32 &other) const
 The distance between two PCG32 pseudorandom number generators.
 
template<typename R = int64_t>
distance (const pcg32 &other) const
 The distance between two PCG32 pseudorandom number generators.
 
template<typename R = int64_t, typename T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
distance (T other_state) const
 The distance between two states.
 
template<typename T >
void advance (T distance)
 Multi-step advance function (jump-ahead, jump-back).
 
bool operator== (const pcg32 &other) const
 Equality operator.
 
bool operator!= (const pcg32 &other) const
 Inequality operator.
 
- Public Member Functions inherited from prrng::GeneratorBase< pcg32 >
double cumsum_random (size_t n)
 Result of the cumulative sum of n random numbers.
 
double cumsum_delta (size_t n, double scale=1)
 Result of the cumulative sum of n 'random' numbers, distributed according to a delta distribution,.
 
double cumsum_exponential (size_t n, double scale=1)
 Result of the cumulative sum of n random numbers, distributed according to an exponential distribution, see exponential_distribution(),.
 
double cumsum_power (size_t n, double k=1)
 Result of the cumulative sum of n random numbers, distributed according to a power distribution, see power_distribution(),.
 
double cumsum_gamma (size_t n, double k=1, double scale=1)
 Result of the cumulative sum of n random numbers, distributed according to a gamma distribution, see gamma_distribution(),.
 
double cumsum_pareto (size_t n, double k=1, double scale=1)
 Result of the cumulative sum of n random numbers, distributed according to a Pareto distribution, see pareto_distribution(),.
 
double cumsum_weibull (size_t n, double k=1, double scale=1)
 Result of the cumulative sum of n random numbers, distributed according to a weibull distribution, see weibull_distribution(),.
 
double cumsum_normal (size_t n, double mu=0, double sigma=1)
 Result of the cumulative sum of n random numbers, distributed according to a normal distribution, see normal_distribution(),.
 
void shuffle (Iterator begin, Iterator end)
 Draw uniformly distributed permutation and permute the given STL container.
 
auto decide (const P &p) -> typename detail::return_type< bool, P >::type
 Decide based on probability per value.
 
decide (const P &p)
 Decide based on probability per value.
 
void decide (const P &p, R &ret)
 Decide based on probability per value.
 
auto decide_masked (const P &p, const T &mask) -> typename detail::return_type< bool, P >::type
 Decide based on probability per value.
 
decide_masked (const P &p, const T &mask)
 Decide based on probability per value.
 
void decide_masked (const P &p, const T &mask, R &ret)
 Decide based on probability per value.
 
double random ()
 Generate a random number \( 0 \leq r \leq 1 \).
 
auto random (const S &shape) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers \( 0 \leq r \leq 1 \).
 
random (const S &shape)
 Generate an nd-array of random numbers \( 0 \leq r \leq 1 \).
 
auto random (const I(&shape)[L]) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers \( 0 \leq r \leq 1 \).
 
random (const I(&shape)[L])
 Generate an nd-array of random numbers \( 0 \leq r \leq 1 \).
 
randint (T high)
 Generate a random integer \( 0 \leq r < bound \).
 
auto randint (const S &shape, T high) -> typename detail::return_type< T, S >::type
 Generate an nd-array of random integers \( 0 \leq r \leq bound \).
 
randint (const S &shape, T high)
 Generate an nd-array of random integers \( 0 \leq r \leq bound \).
 
auto randint (const I(&shape)[L], T high) -> typename detail::return_type_fixed< T, L >::type
 Generate an nd-array of random integers \( 0 \leq r \leq bound \).
 
randint (const I(&shape)[L], T high)
 Generate an nd-array of random integers \( 0 \leq r \leq bound \).
 
auto randint (const S &shape, T low, U high) -> typename detail::return_type< T, S >::type
 Generate an nd-array of random integers \( low \leq r < high \).
 
randint (const S &shape, T low, U high)
 Generate an nd-array of random integers \( low \leq r < high \).
 
auto randint (const I(&shape)[L], T low, U high) -> typename detail::return_type_fixed< T, L >::type
 Generate an nd-array of random integers \( low \leq r < high \).
 
randint (const I(&shape)[L], T low, U high)
 Generate an nd-array of random integers \( low \leq r < high \).
 
double delta (double scale=1)
 Return a number distributed according to a delta distribution.
 
auto delta (const S &shape, double scale=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of numbers that are delta distribution.
 
delta (const S &shape, double scale=1)
 Generate an nd-array of numbers that are delta distribution.
 
auto delta (const I(&shape)[L], double scale=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of numbers that are delta distribution.
 
delta (const I(&shape)[L], double scale=1)
 Generate an nd-array of numbers that are delta distribution.
 
double exponential (double scale=1)
 Return a random number distributed according to an exponential distribution.
 
auto exponential (const S &shape, double scale=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to an exponential distribution.
 
exponential (const S &shape, double scale=1)
 Generate an nd-array of random numbers distributed according to an exponential distribution.
 
auto exponential (const I(&shape)[L], double scale=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to an exponential distribution.
 
exponential (const I(&shape)[L], double scale=1)
 Generate an nd-array of random numbers distributed according to an exponential distribution.
 
double power (double k=1)
 Return a random number distributed according to an power distribution.
 
auto power (const S &shape, double k=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to an power distribution.
 
power (const S &shape, double k=1)
 Generate an nd-array of random numbers distributed according to an power distribution.
 
auto power (const I(&shape)[L], double k=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to an power distribution.
 
power (const I(&shape)[L], double k=1)
 Generate an nd-array of random numbers distributed according to an power distribution.
 
double gamma (double k=1, double scale=1)
 Return a random number distributed according to a Gamma distribution.
 
auto gamma (const S &shape, double k=1, double scale=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to a Gamma distribution.
 
gamma (const S &shape, double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Gamma distribution.
 
auto gamma (const I(&shape)[L], double k=1, double scale=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to a Gamma distribution.
 
gamma (const I(&shape)[L], double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Gamma distribution.
 
double pareto (double k=1, double scale=1)
 Return a random number distributed according to a Pareto distribution.
 
auto pareto (const S &shape, double k=1, double scale=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to a Pareto distribution.
 
pareto (const S &shape, double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Pareto distribution.
 
auto pareto (const I(&shape)[L], double k=1, double scale=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to a Pareto distribution.
 
pareto (const I(&shape)[L], double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Pareto distribution.
 
double weibull (double k=1, double scale=1)
 Return a random number distributed according to a Weibull distribution.
 
auto weibull (const S &shape, double k=1, double scale=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to a Weibull distribution.
 
weibull (const S &shape, double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Weibull distribution.
 
auto weibull (const I(&shape)[L], double k=1, double scale=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to a Weibull distribution.
 
weibull (const I(&shape)[L], double k=1, double scale=1)
 Generate an nd-array of random numbers distributed according to a Weibull distribution.
 
double normal (double mu=0, double sigma=1)
 Return a random number distributed according to a normal distribution.
 
auto normal (const S &shape, double mu=0, double sigma=1) -> typename detail::return_type< double, S >::type
 Generate an nd-array of random numbers distributed according to a normal distribution.
 
normal (const S &shape, double mu=0, double sigma=1)
 Generate an nd-array of random numbers distributed according to a normal distribution.
 
auto normal (const I(&shape)[L], double mu=0, double sigma=1) -> typename detail::return_type_fixed< double, L >::type
 Generate an nd-array of random numbers distributed according to a normal distribution.
 
normal (const I(&shape)[L], double mu=0, double sigma=1)
 Generate an nd-array of random numbers distributed according to a normal distribution.
 
double draw (enum prrng::distribution distribution, std::vector< double > parameters=std::vector< double >{}, bool append_default=true)
 Get a random number according to some distribution.
 
draw (const S &shape, enum prrng::distribution distribution, std::vector< double > parameters=std::vector< double >{}, bool append_default=true)
 Get an nd-array of random numbers according to some distribution.
 
double cumsum (size_t n, enum prrng::distribution distribution, std::vector< double > parameters=std::vector< double >{}, bool append_default=true)
 Get the cumulative sum of n random numbers according to some distribution.
 

Additional Inherited Members

- Protected Attributes inherited from prrng::pcg32
uint64_t m_initstate
 State initiator.
 
uint64_t m_initseq
 Sequence initiator.
 
uint64_t m_state
 RNG state. All values are possible.
 
uint64_t m_inc
 Controls which RNG sequence (stream) is selected. Must always be odd.
 

Detailed Description

Overload of prrng::pcg32() that keeps track of the current index of the generator in the sequence.

Warning
The user is responsible for updating the index. The purpose of this class is therefore mostly internal, to support prrng::pcg32_cumsum().

Definition at line 3329 of file prrng.h.

Constructor & Destructor Documentation

◆ pcg32_index()

template<typename T = uint64_t, typename S = uint64_t>
prrng::pcg32_index::pcg32_index ( initstate = 0x853c49e6748fea9bULL,
initseq = 0xda3e39cb94b95bdbULL,
bool  delta = false 
)
inline
Parameters
initstateState initiator.
initseqSequence initiator.
deltatrue if uniquely a delta distribution will be drawn.

Definition at line 3341 of file prrng.h.

Member Function Documentation

◆ drawn()

void prrng::pcg32_index::drawn ( ptrdiff_t  n)
inline

Update the generator index with the number of items you have drawn.

Parameters
nNumber of drawn numbers.

Definition at line 3392 of file prrng.h.

◆ index()

ptrdiff_t prrng::pcg32_index::index ( ) const
inline

Get the generator index.

Returns
Index of the generator.

Definition at line 3413 of file prrng.h.

◆ jump_to()

void prrng::pcg32_index::jump_to ( ptrdiff_t  index)
inline

Move to a certain index.

Parameters
indexIndex of the generator.

Definition at line 3379 of file prrng.h.

◆ set_delta()

void prrng::pcg32_index::set_delta ( bool  delta)
inline

Signal if the generator is uniquely used to draw a delta distribution.

Parameters
deltatrue if uniquely a delta distribution will be drawn.

Definition at line 3404 of file prrng.h.

◆ set_index()

void prrng::pcg32_index::set_index ( ptrdiff_t  index)
inline

Overwrite the generator index.

Parameters
indexIndex of the generator.

Definition at line 3422 of file prrng.h.

◆ state_at()

uint64_t prrng::pcg32_index::state_at ( ptrdiff_t  index)
inline

State at a specific index of the sequence.

Internally the generator is moved to the index, the state is stored, and the generator is restored to its original state. This call can therefore be expensive.

Parameters
indexIndex at which to get the state.
Returns
uint64_t

Definition at line 3363 of file prrng.h.


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