Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
multipathvariategenerator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file multipathvariategenerator.hpp
20 \brief multi path generators returning the generating N(0,1) variates, this is very much in parallel to the
21 MultiPathGeneratorBase interface and derived classes, including the make function
22 \ingroup models
23*/
24
25#pragma once
26
28
29namespace QuantExt {
30
32public:
33 MultiPathVariateGeneratorBase(const Size dimension, const Size timeSteps);
35 virtual Sample<std::vector<Array>> next() const;
36 virtual void reset() = 0;
37
38protected:
39 virtual Sample<std::vector<Real>> nextSequence() const = 0;
40
43};
44
46public:
47 MultiPathVariateGeneratorMersenneTwister(const Size dimension, const Size timeSteps, BigNatural seed = 0,
48 bool antitheticSampling = false);
49 void reset() override;
50
51private:
52 Sample<std::vector<Real>> nextSequence() const override;
53
54 BigNatural seed_;
56 mutable bool antitheticVariate_;
57
58 QuantLib::ext::shared_ptr<PseudoRandom::rsg_type> rsg_;
59};
60
62public:
63 MultiPathVariateGeneratorMersenneTwisterAntithetic(const Size dimension, const Size timeSteps, BigNatural seed = 0)
64 : MultiPathVariateGeneratorMersenneTwister(dimension, timeSteps, seed, true){};
65};
66
68public:
69 MultiPathVariateGeneratorSobol(const Size dimension, const Size timeSteps, BigNatural seed = 0,
70 SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7);
71 void reset() override;
72
73private:
74 Sample<std::vector<Real>> nextSequence() const override;
75
76 BigNatural seed_;
77 SobolRsg::DirectionIntegers directionIntegers_;
78
79 QuantLib::ext::shared_ptr<LowDiscrepancy::rsg_type> rsg_;
80};
81
83public:
84 MultiPathVariateGeneratorBurley2020Sobol(const Size dimension, const Size timeSteps, BigNatural seed = 42,
85 SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7, BigNatural scrambleSeed = 43);
86 void reset() override;
87
88private:
89 Sample<std::vector<Real>> nextSequence() const override;
90
91 BigNatural seed_;
92 SobolRsg::DirectionIntegers directionIntegers_;
93 BigNatural scrambleSeed_;
94
95 QuantLib::ext::shared_ptr<InverseCumulativeRsg<Burley2020SobolRsg, InverseCumulativeNormal>> rsg_;
96};
97
99public:
101 const Size dimension, const Size timeSteps,
102 SobolBrownianGenerator::Ordering ordering = SobolBrownianGenerator::Steps, BigNatural seed = 0,
103 SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7);
104 Sample<std::vector<Array>> next() const override;
105
106protected:
107 Sample<std::vector<Real>> nextSequence() const override;
108
109 SobolBrownianGenerator::Ordering ordering_;
110 BigNatural seed_;
111 SobolRsg::DirectionIntegers directionIntegers_;
112
113 QuantLib::ext::shared_ptr<SobolBrownianGeneratorBase> gen_;
114};
115
117public:
119 const Size dimension, const Size timeSteps,
120 SobolBrownianGenerator::Ordering ordering = SobolBrownianGenerator::Steps, BigNatural seed = 42,
121 SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7);
122 void reset() override final;
123};
124
126public:
128 const Size dimension, const Size timeSteps,
129 SobolBrownianGenerator::Ordering ordering = SobolBrownianGenerator::Steps, BigNatural seed = 42,
130 SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7, BigNatural scrambleSeed = 43);
131 void reset() override final;
132
133protected:
134 BigNatural scrambleSeed_;
135};
136
137QuantLib::ext::shared_ptr<MultiPathVariateGeneratorBase>
138makeMultiPathVariateGenerator(const SequenceType s, const Size dimension, const Size timeSteps, const BigNatural seed,
139 const SobolBrownianGenerator::Ordering ordering = SobolBrownianGenerator::Steps,
140 const SobolRsg::DirectionIntegers directionIntegers = SobolRsg::JoeKuoD7);
141
142} // namespace QuantExt
virtual Sample< std::vector< Real > > nextSequence() const =0
virtual Sample< std::vector< Array > > next() const
QuantLib::ext::shared_ptr< InverseCumulativeRsg< Burley2020SobolRsg, InverseCumulativeNormal > > rsg_
Sample< std::vector< Real > > nextSequence() const override
MultiPathVariateGeneratorMersenneTwisterAntithetic(const Size dimension, const Size timeSteps, BigNatural seed=0)
Sample< std::vector< Real > > nextSequence() const override
QuantLib::ext::shared_ptr< PseudoRandom::rsg_type > rsg_
Sample< std::vector< Real > > nextSequence() const override
QuantLib::ext::shared_ptr< SobolBrownianGeneratorBase > gen_
Sample< std::vector< Real > > nextSequence() const override
QuantLib::ext::shared_ptr< LowDiscrepancy::rsg_type > rsg_
base class for multi path generators
QuantLib::ext::shared_ptr< MultiPathVariateGeneratorBase > makeMultiPathVariateGenerator(const SequenceType s, const Size dimension, const Size timeSteps, const BigNatural seed, const SobolBrownianGenerator::Ordering ordering, const SobolRsg::DirectionIntegers directionIntegers)