QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
sobolbrowniangenerator.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20
21#ifndef quantlib_sobol_brownian_generator_hpp
22#define quantlib_sobol_brownian_generator_hpp
23
30#include <vector>
31
32namespace QuantLib {
33
34 //! Sobol Brownian generator for market-model simulations
35 /*! Incremental Brownian generator using a Sobol generator,
36 inverse-cumulative Gaussian method, and Brownian bridging.
37 */
39 public:
40 enum Ordering {
41 Factors, /*!< The variates with the best quality will be
42 used for the evolution of the first factor. */
43 Steps, /*!< The variates with the best quality will be
44 used for the largest steps of all factors. */
45 Diagonal /*!< A diagonal schema will be used to assign
46 the variates with the best quality to the
47 most important factors and the largest
48 steps. */
49 };
51 Size factors,
52 Size steps,
53 Ordering ordering);
54
55 Real nextPath() override;
56 Real nextStep(std::vector<Real>&) override;
57
58 Size numberOfFactors() const override;
59 Size numberOfSteps() const override;
60
61 // test interface
62 const std::vector<std::vector<Size> >& orderedIndices() const;
63 std::vector<std::vector<Real> > transform(
64 const std::vector<std::vector<Real> >& variates);
65
66 protected:
67 virtual const SobolRsg::sample_type& nextSequence() = 0;
68
69 private:
73 // work variables
75 std::vector<std::vector<Size> > orderedIndices_;
76 std::vector<std::vector<Real> > bridgedVariates_;
77 };
78
80 public:
82 Size steps,
83 Ordering ordering,
84 unsigned long seed = 0,
86
87 private:
88 const SobolRsg::sample_type& nextSequence() override;
90 };
91
93 public:
96 unsigned long seed = 0,
98 ext::shared_ptr<BrownianGenerator> create(Size factors, Size steps) const override;
99
100 private:
102 unsigned long seed_;
104 };
105
107 public:
109 Size factors,
110 Size steps,
111 Ordering ordering,
112 unsigned long seed = 42,
114 unsigned long scrambleSeed = 43);
115
116 private:
119 };
120
122 public:
125 unsigned long seed = 42,
127 unsigned long scrambleSeed = 43);
128 ext::shared_ptr<BrownianGenerator> create(Size factors, Size steps) const override;
129
130 private:
132 unsigned long seed_;
134 unsigned long scrambleSeed_;
135 };
136
137}
138
139
140#endif
Browian bridge.
scrambled Sobol sequence following Burley, 2020
Builds Wiener process paths using Gaussian variates.
ext::shared_ptr< BrownianGenerator > create(Size factors, Size steps) const override
const Burley2020SobolRsg::sample_type & nextSequence() override
InverseCumulativeRsg< Burley2020SobolRsg, InverseCumulativeNormal > generator_
Inverse cumulative random sequence generator.
Sobol Brownian generator for market-model simulations.
std::vector< std::vector< Size > > orderedIndices_
std::vector< std::vector< Real > > transform(const std::vector< std::vector< Real > > &variates)
Real nextStep(std::vector< Real > &) override
virtual const SobolRsg::sample_type & nextSequence()=0
std::vector< std::vector< Real > > bridgedVariates_
const std::vector< std::vector< Size > > & orderedIndices() const
SobolBrownianGenerator::Ordering ordering_
ext::shared_ptr< BrownianGenerator > create(Size factors, Size steps) const override
InverseCumulativeRsg< SobolRsg, InverseCumulativeNormal > generator_
const SobolRsg::sample_type & nextSequence() override
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Inverse cumulative random sequence generator.
Definition: any.hpp:35
normal, cumulative and inverse cumulative distributions
Sobol low-discrepancy sequence generator.