QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
Gaussian random number generator. More...
#include <zigguratgaussianrng.hpp>
Public Types | |
typedef Sample< Real > | sample_type |
Public Member Functions | |
ZigguratGaussianRng (const RNG &uint64Generator) | |
sample_type | next () const |
returns a sample from a Gaussian distribution More... | |
Real | nextReal () const |
return a random number from a Gaussian distribution More... | |
Private Types | |
typedef Real | ZigguratTable[257] |
Private Member Functions | |
Real | pdf (Real x) const |
Real | zeroCase (Real u) const |
compute a random number in the tail by hand More... | |
Real | normR () const |
Real | normX (int i) const |
Real | normF (int i) const |
Private Attributes | |
RNG | uint64Generator_ |
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:
Currently, Xoshiro256StarStarUniformRng is the only RNG supporting this.
Definition at line 56 of file zigguratgaussianrng.hpp.
typedef Sample<Real> sample_type |
Definition at line 58 of file zigguratgaussianrng.hpp.
|
private |
Definition at line 72 of file zigguratgaussianrng.hpp.
|
explicit |
Definition at line 60 of file zigguratgaussianrng.hpp.
sample_type next | ( | ) | const |
returns a sample from a Gaussian distribution
Definition at line 64 of file zigguratgaussianrng.hpp.
Real nextReal |
return a random number from a Gaussian distribution
Definition at line 85 of file zigguratgaussianrng.hpp.
Definition at line 125 of file zigguratgaussianrng.hpp.
compute a random number in the tail by hand
Definition at line 113 of file zigguratgaussianrng.hpp.
|
private |
Definition at line 130 of file zigguratgaussianrng.hpp.
|
private |
Definition at line 135 of file zigguratgaussianrng.hpp.
|
private |
Definition at line 206 of file zigguratgaussianrng.hpp.
|
private |
Definition at line 70 of file zigguratgaussianrng.hpp.