prrng 1.12.1
Loading...
Searching...
No Matches
prrng Namespace Reference

Portable Reconstructible (Pseudo!) Random Number Generator. More...

Classes

struct  alignment
 Structure to assemble the alignment parameters. More...
 
class  exponential_distribution
 Exponential distribution. More...
 
class  gamma_distribution
 Gamma distribution. More...
 
class  GeneratorBase
 Base class of the pseudorandom number generators providing common methods. More...
 
class  GeneratorBase_array
 Base class of an array of pseudorandom number generators. More...
 
class  normal_distribution
 Normal distribution. More...
 
class  pareto_distribution
 Pareto distribution. More...
 
class  pcg32
 Random number generate using the pcg32 algorithm. More...
 
class  pcg32_array
 Array of independent generators. More...
 
class  pcg32_array_chunk
 Array of generators of which a chunk of the random sequence is kept in memory. More...
 
class  pcg32_array_cumsum
 Array of generators of a random cumulative sum, see prrng::pcg32_cumsum(). More...
 
class  pcg32_arrayBase
 Base class, see pcg32_array for description. More...
 
class  pcg32_arrayBase_chunk
 Array of generators of which a chunk of random numbers is kept in memory. More...
 
class  pcg32_arrayBase_chunkBase
 Array of generators of which a chunk of random numbers is kept in memory. More...
 
class  pcg32_arrayBase_cumsum
 TODO: copydoc. More...
 
class  pcg32_cumsum
 Generator of a random cumulative sum of which a chunk is kept in memory. More...
 
class  pcg32_index
 Overload of prrng::pcg32() that keeps track of the current index of the generator in the sequence. More...
 
class  pcg32_index_array
 Array of prrng::pcg32_index(). More...
 
class  pcg32_index_tensor
 Fixed rank version of pcg32_index_array. More...
 
class  pcg32_tensor
 Fixed rank version of pcg32_array. More...
 
class  pcg32_tensor_chunk
 Array of generators of which a chunk of the random sequence is kept in memory. More...
 
class  pcg32_tensor_cumsum
 Array of generators of a random cumulative sum, see prrng::pcg32_cumsum(). More...
 
class  power_distribution
 Power distribution. More...
 
class  weibull_distribution
 Weibull distribution. More...
 

Enumerations

enum  distribution {
  random , delta , exponential , power ,
  gamma , pareto , weibull , normal ,
  custom
}
 Distribution identifier. More...
 

Functions

std::vector< double > default_parameters (enum distribution distribution, const std::vector< double > &parameters=std::vector< double >{})
 
std::string version ()
 Version string, e.g.
 
std::vector< std::string > version_dependencies ()
 Versions of this library and of all of its dependencies.
 
std::vector< std::string > version_compiler ()
 Information on the compiler, the platform, the C++ standard, and the compilation date.
 
template<class T , class V , class R >
lower_bound (const T &matrix, const V &value, const R &index, size_t proximity=10)
 Iterating on the last axis of an nd-array (e.g.
 
template<class T , class V , class R >
lower_bound (const T &matrix, const V &value)
 Iterating on the last axis of an nd-array (e.g.
 
template<class V , class I >
cumsum_chunk (const V &cumsum, const V &delta, const I &shift)
 Update the chunk of a cumsum computed and stored in chunks.
 
template<class T >
auto auto_pcg32 (const T &initstate)
 Return a pcg32, a pcg32_array, or a pcg32_tensor based on input.
 
template<class T , class S >
auto auto_pcg32 (const T &initstate, const S &initseq)
 Return a pcg32, a pcg32_array, or a pcg32_tensor based on input.
 

Detailed Description

Portable Reconstructible (Pseudo!) Random Number Generator.

Enumeration Type Documentation

◆ distribution

Distribution identifier.

Enumerator
random 

flat

delta 

delta

exponential 

exponential

power 

power

gamma 

gamma

pareto 

pareto

weibull 

weibull

normal 

normal

custom 

unknown

Definition at line 193 of file prrng.h.

Function Documentation

◆ auto_pcg32() [1/2]

template<class T >
auto prrng::auto_pcg32 ( const T &  initstate)
inline

Return a pcg32, a pcg32_array, or a pcg32_tensor based on input.

Parameters
initstateThe sequence initiator.
Returns
The allocated generator.

Definition at line 5769 of file prrng.h.

◆ auto_pcg32() [2/2]

template<class T , class S >
auto prrng::auto_pcg32 ( const T &  initstate,
const S &  initseq 
)
inline

Return a pcg32, a pcg32_array, or a pcg32_tensor based on input.

Parameters
initstateThe sequence initiator.
initseqThe sequence initiator.
Returns
The allocated generator.

Definition at line 5782 of file prrng.h.

◆ cumsum_chunk()

template<class V , class I >
V prrng::cumsum_chunk ( const V &  cumsum,
const V &  delta,
const I &  shift 
)
inline

Update the chunk of a cumsum computed and stored in chunks.

Example

Consider a full array:

da = np.random.random(N)
a = np.cumsum(a)

With chunk settings:

n = ...  # size of each new chunk
nbuffer = ... # number of items to buffer

The the first chunk:

chunk = np.copy(a[:n + nbuffer])
nchunk = n + nbuffer
istart = np.array(0)

Then, moving right:

prrng.cumsum_chunk_inplace(chunk, da[istart + nchunk : istart + nchunk + n], n)
istart += n

Or, moving left:

prrng.cumsum_chunk_inplace(chunk, da[istart - n : istart + 1], -n)
istart -= n
Parameters
cumsumThe current chunk of the cumsum.
deltaThe 'diff's of the next chunk in the cumsum.
shiftThe shift per row.
Returns
Same shape as cumsum.

Definition at line 898 of file prrng.h.

◆ default_parameters()

std::vector< double > prrng::default_parameters ( enum distribution  distribution,
const std::vector< double > &  parameters = std::vector<double>{} 
)

Parameters
distributionDistribution.
parametersParameters for the distribution: appended by the following defaults if needed.

Definition at line 225 of file prrng.h.

◆ lower_bound() [1/2]

template<class T , class V , class R >
R prrng::lower_bound ( const T &  matrix,
const V &  value 
)
inline

Iterating on the last axis of an nd-array (e.g.

per row of a rank 2 matrix): Return index of the first element in the range [first, last) such that element < value is false (i.e. greater or equal to), or last if no such element is found.

Parameters
matrixThe matrix defining a range per row.
valueThe value to find (per row).
Returns
Same shape as value.

Definition at line 854 of file prrng.h.

◆ lower_bound() [2/2]

template<class T , class V , class R >
R prrng::lower_bound ( const T &  matrix,
const V &  value,
const R &  index,
size_t  proximity = 10 
)
inline

Iterating on the last axis of an nd-array (e.g.

per row of a rank 2 matrix): Return index of the first element in the range [first, last) such that element < value is false (i.e. greater or equal to), or last if no such element is found.

This function allows for a guess of the index and a proximity search around. This could be efficient for finding items in large arrays.

Parameters
matrixThe matrix defining a range per row.
valueThe value to find (per row).
indexInitial guess on index.
proximitySize of the proximity search around guess (use 0 to disable proximity search).
Returns
Same shape as index.

Definition at line 837 of file prrng.h.

◆ version()

std::string prrng::version ( )
inline

Version string, e.g.

"0.8.0".

Returns
String.

Definition at line 547 of file prrng.h.

◆ version_compiler()

std::vector< std::string > prrng::version_compiler ( )
inline

Information on the compiler, the platform, the C++ standard, and the compilation date.

Returns
List of strings.

Definition at line 617 of file prrng.h.

◆ version_dependencies()

std::vector< std::string > prrng::version_dependencies ( )
inline

Versions of this library and of all of its dependencies.

The output is a list of strings, e.g.:

"prrng=1.7.0",
"xtensor=0.20.1"
...
Returns
List of strings.

Definition at line 563 of file prrng.h.