Class NormalDist
Defined in File RandomDist.hpp
Class Documentation
-
class NormalDist
Normal distribution.
Draws normal deviates using the Marsaglia polar method, which generates deviates in pairs: the first call draws a pair and returns one member of it, and the second call returns the other member without consuming any engine output. This reproduces libstdc++’s std::normal_distribution<double>.
Because of this saved deviate, an object’s draws are determined by the engine state only together with whether a deviate is saved. To keep runs reproducible from a recorded rng state (see RngThread::getState), an object of this class – or of any class that holds one, i.e., LognormalDist and PoissonDist – must never outlive a point at which the rng state is saved or restored. In practice this means constructing it locally within the function that draws from it, as pdfs::PDFSegmentNormal::draw does, rather than storing it as a long-lived member.
Public Functions
-
inline explicit NormalDist(const double mean = 0.0, const double stddev = 1.0)
Construct a NormalDist.
- Parameters:
mean – The mean of the distribution
stddev – The standard deviation of the distribution
-
inline explicit NormalDist(const double mean = 0.0, const double stddev = 1.0)