QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
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
28#include <vector>
29
30namespace 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:
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:
57 mutable unsigned long sequenceCounter_ = 0;
59 std::vector<unsigned long> randomStart_;
60 std::vector<Real> randomShift_;
61 };
62}
63
64
65#endif
Halton low-discrepancy sequence generator.
Definition: haltonrsg.hpp:43
const sample_type & nextSequence() const
Definition: haltonrsg.cpp:56
std::vector< Real > randomShift_
Definition: haltonrsg.hpp:60
Size dimension() const
Definition: haltonrsg.hpp:54
sample_type sequence_
Definition: haltonrsg.hpp:58
const sample_type & lastSequence() const
Definition: haltonrsg.hpp:51
unsigned long sequenceCounter_
Definition: haltonrsg.hpp:57
Sample< std::vector< Real > > sample_type
Definition: haltonrsg.hpp:45
std::vector< unsigned long > randomStart_
Definition: haltonrsg.hpp:59
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
weighted sample
weighted sample
Definition: sample.hpp:35