QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
randomnumbers
haltonrsg.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) 2003 Ferdinando Ametrano
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
/*! \file haltonrsg.hpp
21
\brief Halton low-discrepancy sequence generator
22
*/
23
24
#ifndef quantlib_halton_ld_rsg_h
25
#define quantlib_halton_ld_rsg_h
26
27
#include <
ql/methods/montecarlo/sample.hpp
>
28
#include <vector>
29
30
namespace
QuantLib
{
31
32
//! Halton low-discrepancy sequence generator
33
/*! Halton algorithm for low-discrepancy sequence. For more
34
details see chapter 8, paragraph 2 of "Monte Carlo Methods in
35
Finance", by Peter Jäckel
36
37
\test
38
- the correctness of the returned values is tested by
39
reproducing known good values.
40
- the correctness of the returned values is tested by checking
41
their discrepancy against known good values.
42
*/
43
class
HaltonRsg
{
44
public
:
45
typedef
Sample<std::vector<Real>
>
sample_type
;
46
explicit
HaltonRsg
(
Size
dimensionality,
47
unsigned
long
seed = 0,
48
bool
randomStart =
true
,
49
bool
randomShift =
false
);
50
const
sample_type
&
nextSequence
()
const
;
51
const
sample_type
&
lastSequence
()
const
{
52
return
sequence_
;
53
}
54
Size
dimension
()
const
{
return
dimensionality_
;}
55
private
:
56
Size
dimensionality_
;
57
mutable
unsigned
long
sequenceCounter_
= 0;
58
mutable
sample_type
sequence_
;
59
std::vector<unsigned long>
randomStart_
;
60
std::vector<Real>
randomShift_
;
61
};
62
}
63
64
65
#endif
QuantLib::HaltonRsg
Halton low-discrepancy sequence generator.
Definition:
haltonrsg.hpp:43
QuantLib::HaltonRsg::nextSequence
const sample_type & nextSequence() const
Definition:
haltonrsg.cpp:56
QuantLib::HaltonRsg::randomShift_
std::vector< Real > randomShift_
Definition:
haltonrsg.hpp:60
QuantLib::HaltonRsg::dimension
Size dimension() const
Definition:
haltonrsg.hpp:54
QuantLib::HaltonRsg::sequence_
sample_type sequence_
Definition:
haltonrsg.hpp:58
QuantLib::HaltonRsg::dimensionality_
Size dimensionality_
Definition:
haltonrsg.hpp:56
QuantLib::HaltonRsg::lastSequence
const sample_type & lastSequence() const
Definition:
haltonrsg.hpp:51
QuantLib::HaltonRsg::sequenceCounter_
unsigned long sequenceCounter_
Definition:
haltonrsg.hpp:57
QuantLib::HaltonRsg::sample_type
Sample< std::vector< Real > > sample_type
Definition:
haltonrsg.hpp:45
QuantLib::HaltonRsg::randomStart_
std::vector< unsigned long > randomStart_
Definition:
haltonrsg.hpp:59
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
QuantLib
Definition:
any.hpp:35
sample.hpp
weighted sample
QuantLib::Sample
weighted sample
Definition:
sample.hpp:35
Generated by
Doxygen
1.9.5