Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MultiPathVariateGeneratorMersenneTwister Class Reference

#include <qle/methods/multipathvariategenerator.hpp>

+ Inheritance diagram for MultiPathVariateGeneratorMersenneTwister:
+ Collaboration diagram for MultiPathVariateGeneratorMersenneTwister:

Public Member Functions

 MultiPathVariateGeneratorMersenneTwister (const Size dimension, const Size timeSteps, BigNatural seed=0, bool antitheticSampling=false)
 
void reset () override
 
- Public Member Functions inherited from MultiPathVariateGeneratorBase
 MultiPathVariateGeneratorBase (const Size dimension, const Size timeSteps)
 
virtual ~MultiPathVariateGeneratorBase ()
 
virtual Sample< std::vector< Array > > next () const
 
virtual void reset ()=0
 

Private Member Functions

Sample< std::vector< Real > > nextSequence () const override
 

Private Attributes

BigNatural seed_
 
bool antitheticSampling_
 
bool antitheticVariate_
 
QuantLib::ext::shared_ptr< PseudoRandom::rsg_type > rsg_
 

Additional Inherited Members

virtual Sample< std::vector< Real > > nextSequence () const =0
 
- Protected Attributes inherited from MultiPathVariateGeneratorBase
Size dimension_
 
Size timeSteps_
 

Detailed Description

Definition at line 45 of file multipathvariategenerator.hpp.

Constructor & Destructor Documentation

◆ MultiPathVariateGeneratorMersenneTwister()

MultiPathVariateGeneratorMersenneTwister ( const Size  dimension,
const Size  timeSteps,
BigNatural  seed = 0,
bool  antitheticSampling = false 
)

Member Function Documentation

◆ reset()

void reset ( )
overridevirtual

Implements MultiPathVariateGeneratorBase.

Definition at line 53 of file multipathvariategenerator.cpp.

53 {
54 rsg_ = QuantLib::ext::make_shared<
55 InverseCumulativeRsg<RandomSequenceGenerator<MersenneTwisterUniformRng>, InverseCumulativeNormal>>(
56 RandomSequenceGenerator<MersenneTwisterUniformRng>(dimension_ * timeSteps_, MersenneTwisterUniformRng(seed_)),
57 InverseCumulativeNormal());
58 antitheticVariate_ = true;
59}
QuantLib::ext::shared_ptr< PseudoRandom::rsg_type > rsg_
+ Here is the caller graph for this function:

◆ nextSequence()

Sample< std::vector< Real > > nextSequence ( ) const
overrideprivatevirtual

Implements MultiPathVariateGeneratorBase.

Definition at line 61 of file multipathvariategenerator.cpp.

61 {
65 auto tmp = rsg_->lastSequence();
66 std::transform(tmp.value.begin(), tmp.value.end(), tmp.value.begin(), std::negate<Real>());
67 return tmp;
68 } else {
69 return rsg_->nextSequence();
70 }
71 }
72 return rsg_->nextSequence();
73}

Member Data Documentation

◆ seed_

BigNatural seed_
private

Definition at line 54 of file multipathvariategenerator.hpp.

◆ antitheticSampling_

bool antitheticSampling_
private

Definition at line 55 of file multipathvariategenerator.hpp.

◆ antitheticVariate_

bool antitheticVariate_
mutableprivate

Definition at line 56 of file multipathvariategenerator.hpp.

◆ rsg_

QuantLib::ext::shared_ptr<PseudoRandom::rsg_type> rsg_
private

Definition at line 58 of file multipathvariategenerator.hpp.