QuantLib: a free/open-source library for quantitative finance
Reference manual - version 1.40
Loading...
Searching...
No Matches
ZigguratGaussianRng< RNG > Class Template Reference

Gaussian random number generator. More...

#include <ql/math/randomnumbers/zigguratgaussianrng.hpp>

Public Types

typedef Sample< Realsample_type

Public Member Functions

 ZigguratGaussianRng (const RNG &uint64Generator)
sample_type next () const
 returns a sample from a Gaussian distribution
Real nextReal () const
 return a random number from a Gaussian distribution

Detailed Description

template<class RNG>
class QuantLib::ZigguratGaussianRng< RNG >

Gaussian random number generator.

It uses the Ziggurat transformation to return a normal distributed Gaussian deviate with average 0.0 and standard deviation of 1.0, from a random integer in the [0,0xffffffffffffffffULL]-interval like.

For a more detailed description see the article "An Improved Ziggurat Method to Generate Normal Random Samples" by Jurgen A. Doornik (https://www.doornik.com/research/ziggurat.pdf).

The code here is inspired by the rust implementation in https://github.com/rust-random/rand/blob/d42daabf65a3ceaf58c2eefc7eb477c4d5a9b4ba/rand_distr/src/normal.rs and https://github.com/rust-random/rand/blob/d42daabf65a3ceaf58c2eefc7eb477c4d5a9b4ba/rand_distr/src/utils.rs.

Class RNG must implement the following interface:

Real nextReal() const;
std::uint64_t nextInt64() const;

Currently, Xoshiro256StarStarUniformRng is the only RNG supporting this.