QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
BoxMullerGaussianRng< RNG > Class Template Reference

Gaussian random number generator. More...

#include <boxmullergaussianrng.hpp>

+ Collaboration diagram for BoxMullerGaussianRng< RNG >:

Public Types

typedef Sample< Realsample_type
 
typedef RNG urng_type
 

Public Member Functions

 BoxMullerGaussianRng (const RNG &uniformGenerator)
 
sample_type next () const
 returns a sample from a Gaussian distribution More...
 

Private Attributes

RNG uniformGenerator_
 
bool returnFirst_ = true
 
Real firstValue_
 
Real secondValue_
 
Real firstWeight_
 
Real secondWeight_
 
Real weight_ = 0.0
 

Detailed Description

template<class RNG>
class QuantLib::BoxMullerGaussianRng< RNG >

Gaussian random number generator.

It uses the well-known Box-Muller transformation to return a normal distributed Gaussian deviate with average 0.0 and standard deviation of 1.0, from a uniform deviate in (0,1) supplied by RNG.

Class RNG must implement the following interface:

RNG::sample_type RNG::next() const;
Examples
BasketLosses.cpp.

Definition at line 44 of file boxmullergaussianrng.hpp.

Member Typedef Documentation

◆ sample_type

Definition at line 46 of file boxmullergaussianrng.hpp.

◆ urng_type

typedef RNG urng_type

Definition at line 47 of file boxmullergaussianrng.hpp.

Constructor & Destructor Documentation

◆ BoxMullerGaussianRng()

BoxMullerGaussianRng ( const RNG &  uniformGenerator)
explicit

Definition at line 60 of file boxmullergaussianrng.hpp.

Member Function Documentation

◆ next()

returns a sample from a Gaussian distribution

Definition at line 65 of file boxmullergaussianrng.hpp.

Member Data Documentation

◆ uniformGenerator_

RNG uniformGenerator_
private

Definition at line 52 of file boxmullergaussianrng.hpp.

◆ returnFirst_

bool returnFirst_ = true
mutableprivate

Definition at line 53 of file boxmullergaussianrng.hpp.

◆ firstValue_

Real firstValue_
mutableprivate

Definition at line 54 of file boxmullergaussianrng.hpp.

◆ secondValue_

Real secondValue_
private

Definition at line 54 of file boxmullergaussianrng.hpp.

◆ firstWeight_

Real firstWeight_
mutableprivate

Definition at line 55 of file boxmullergaussianrng.hpp.

◆ secondWeight_

Real secondWeight_
private

Definition at line 55 of file boxmullergaussianrng.hpp.

◆ weight_

Real weight_ = 0.0
mutableprivate

Definition at line 56 of file boxmullergaussianrng.hpp.