QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
zigguratrng.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010 Kakhkhor Abdijalilov
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
24#ifndef quantlib_ziggurat_generator_hpp
25#define quantlib_ziggurat_generator_hpp
26
27#include <ql/math/randomnumbers/mt19937uniformrng.hpp>
28#include <ql/math/randomnumbers/randomsequencegenerator.hpp>
29
30namespace QuantLib {
31
33
53 public:
55 explicit ZigguratRng(unsigned long seed = 0);
56 sample_type next() const { return {nextGaussian(), 1.0}; }
57
58 private:
60 Real nextGaussian() const;
61 };
62
63 // RNG traits for Ziggurat generator
64 struct Ziggurat {
65 // typedefs
68 // more traits
69 enum { allowsErrorEstimate = 1 };
70 // factory
72 BigNatural seed) {
73 return rsg_type(dimension, seed);
74 }
75 };
76
77}
78
79#endif
Uniform random number generator.
Random sequence generator based on a pseudo-random number generator.
Ziggurat random-number generator.
Definition: zigguratrng.hpp:52
sample_type next() const
Definition: zigguratrng.hpp:56
MersenneTwisterUniformRng mt32_
Definition: zigguratrng.hpp:59
Real nextGaussian() const
Sample< Real > sample_type
Definition: zigguratrng.hpp:54
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
unsigned QL_BIG_INTEGER BigNatural
large positive integer
Definition: types.hpp:46
weighted sample
Definition: sample.hpp:35
static rsg_type make_sequence_generator(Size dimension, BigNatural seed)
Definition: zigguratrng.hpp:71
ZigguratRng rng_type
Definition: zigguratrng.hpp:66
RandomSequenceGenerator< rng_type > rsg_type
Definition: zigguratrng.hpp:67