21#include <boost/iterator/permutation_iterator.hpp>
27 void fillByFactor(std::vector<std::vector<Size> >& M,
30 for (
Size i=0; i<factors; ++i)
31 for (
Size j=0; j<steps; ++j)
35 void fillByStep(std::vector<std::vector<Size> >& M,
38 for (
Size j=0; j<steps; ++j)
39 for (
Size i=0; i<factors; ++i)
44 void fillByDiagonal(std::vector<std::vector<Size> >& M,
51 while (counter < factors*steps) {
53 if (i == 0 || j == steps-1) {
113 : factors_(factors), steps_(steps), ordering_(ordering),
114 bridge_(steps), orderedIndices_(factors,
std::vector<
Size>(steps)),
115 bridgedVariates_(factors,
std::vector<
Real>(steps)) {
138 sample.value.begin(),
140 boost::make_permutation_iterator(
141 sample.value.begin(),
146 return sample.weight;
150 const std::vector<std::vector<Size> >&
156 const std::vector<std::vector<Real> >& variates) {
159 "inconsistent variate vector");
162 const Size nPaths = variates.front().size();
164 std::vector<std::vector<Real> >
167 for (
Size j=0; j < nPaths; ++j) {
169 for (
Size k=0; k < dim; ++k) {
170 sample[k] = variates[k][j];
176 boost::make_permutation_iterator(
179 retVal[i].begin()+j*
steps_);
187 #if defined(QL_EXTRA_SAFETY_CHECKS)
217 : ordering_(ordering), seed_(seed), integers_(integers) {}
219 ext::shared_ptr<BrownianGenerator>
221 return ext::shared_ptr<BrownianGenerator>(
232 unsigned long scrambleSeed)
245 unsigned long scrambleSeed)
246 : ordering_(ordering), seed_(seed), integers_(integers), scrambleSeed_(scrambleSeed) {}
248 ext::shared_ptr<BrownianGenerator>
void transform(RandomAccessIterator1 begin, RandomAccessIterator1 end, RandomAccessIterator2 output) const
Brownian-bridge generator function.
SobolBrownianGenerator::Ordering ordering_
Burley2020SobolBrownianGeneratorFactory(SobolBrownianGenerator::Ordering ordering, unsigned long seed=42, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::Jaeckel, unsigned long scrambleSeed=43)
ext::shared_ptr< BrownianGenerator > create(Size factors, Size steps) const override
unsigned long scrambleSeed_
SobolRsg::DirectionIntegers integers_
Burley2020SobolBrownianGenerator(Size factors, Size steps, Ordering ordering, unsigned long seed=42, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::Jaeckel, unsigned long scrambleSeed=43)
const Burley2020SobolRsg::sample_type & nextSequence() override
InverseCumulativeRsg< Burley2020SobolRsg, InverseCumulativeNormal > generator_
Scrambled sobol sequence according to Burley, 2020.
Inverse cumulative normal distribution function.
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_
Size numberOfFactors() const override
SobolBrownianGeneratorBase(Size factors, Size steps, Ordering ordering)
Size numberOfSteps() const override
const std::vector< std::vector< Size > > & orderedIndices() const
SobolBrownianGenerator::Ordering ordering_
ext::shared_ptr< BrownianGenerator > create(Size factors, Size steps) const override
SobolBrownianGeneratorFactory(SobolBrownianGenerator::Ordering ordering, unsigned long seed=0, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::Jaeckel)
SobolRsg::DirectionIntegers integers_
InverseCumulativeRsg< SobolRsg, InverseCumulativeNormal > generator_
SobolBrownianGenerator(Size factors, Size steps, Ordering ordering, unsigned long seed=0, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::Jaeckel)
const SobolRsg::sample_type & nextSequence() override
Sobol low-discrepancy sequence generator.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container