SHiP Random
Random number helpers shared by the SHiP software
Loading...
Searching...
No Matches
SHiP::random::PhiloxRng Class Reference

#include <philox_rng.hpp>

Public Member Functions

 PhiloxRng (std::uint32_t seed, std::uint32_t key_hi=0xBEEFCAFE, std::uint64_t substream=0)
 key_hi selects an independent stream, so different generators seeded
 
double uniform ()
 Uniform in [0, 1), with 32 bits of resolution.
 
double uniform (double lo, double hi)
 Uniform in [lo, hi), with 32 bits of resolution.
 
double uniform53 ()
 Uniform in [0, 1) with full double resolution: combines two consecutive 32-bit Philox words into a 64-bit integer and keeps the top 53 bits.
 
double uniform53 (double lo, double hi)
 Uniform in [lo, hi) with full double resolution.
 
double gaussian (double mean, double sigma, Precision precision=Precision::Bits32)
 Gaussian deviate by the Box–Muller transform, cosine branch only (two uniforms per deviate).
 
double gamma_wh (double alpha, double scale=1, Precision precision=Precision::Bits32)
 
double beta_dist_approx (double alpha, double zeta, Precision precision=Precision::Bits32)
 

Constructor & Destructor Documentation

◆ PhiloxRng()

SHiP::random::PhiloxRng::PhiloxRng ( std::uint32_t  seed,
std::uint32_t  key_hi = 0xBEEFCAFE,
std::uint64_t  substream = 0 
)
inlineexplicit

key_hi selects an independent stream, so different generators seeded

counter range. Use it for per-event sub-streams of one seed without perturbing the key (a key derived as seed ^ event would collide across seeds: XOR is not injective in (seed, event)).

Member Function Documentation

◆ beta_dist_approx()

double SHiP::random::PhiloxRng::beta_dist_approx ( double  alpha,
double  zeta,
Precision  precision = Precision::Bits32 
)
inline

◆ gamma_wh()

double SHiP::random::PhiloxRng::gamma_wh ( double  alpha,
double  scale = 1,
Precision  precision = Precision::Bits32 
)
inline

◆ gaussian()

double SHiP::random::PhiloxRng::gaussian ( double  mean,
double  sigma,
Precision  precision = Precision::Bits32 
)
inline

Gaussian deviate by the Box–Muller transform, cosine branch only (two uniforms per deviate).

The first draw is flipped from [0, 1) to (0, 1] to keep the log argument nonzero.

◆ uniform() [1/2]

double SHiP::random::PhiloxRng::uniform ( )
inline

Uniform in [0, 1), with 32 bits of resolution.

◆ uniform() [2/2]

double SHiP::random::PhiloxRng::uniform ( double  lo,
double  hi 
)
inline

Uniform in [lo, hi), with 32 bits of resolution.

◆ uniform53() [1/2]

double SHiP::random::PhiloxRng::uniform53 ( )
inline

Uniform in [0, 1) with full double resolution: combines two consecutive 32-bit Philox words into a 64-bit integer and keeps the top 53 bits.

Use it when the sampled range spans many orders of magnitude (e.g. ps-scale jitter within a multi-second spill), where uniform() is too coarse. If only one word is left in the buffer, it is skipped.

◆ uniform53() [2/2]

double SHiP::random::PhiloxRng::uniform53 ( double  lo,
double  hi 
)
inline

Uniform in [lo, hi) with full double resolution.


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