File: class_quant_lib_1_1_sobol_rsg.html

package info (click to toggle)
quantlib-refman-html 1.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 103,140 kB
  • sloc: javascript: 13,408; makefile: 35
file content (235 lines) | stat: -rw-r--r-- 14,236 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QuantLib: SobolRsg Class Reference</title>
<link href='https://fonts.googleapis.com/css?family=Merriweather+Sans:800' rel='stylesheet' type='text/css'>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="quantlibextra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://quantlib.org">
       <img alt="QuantLib" src="QL-title.jpg"></a>
   <div id="projectbrief">A free/open-source library for quantitative finance</div>
   <div id="projectnumber">Reference manual - version 1.20</div>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespace_quant_lib.html">QuantLib</a></li><li class="navelem"><a class="el" href="class_quant_lib_1_1_sobol_rsg.html">SobolRsg</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_quant_lib_1_1_sobol_rsg-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">SobolRsg Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Sobol low-discrepancy sequence generator.  
 <a href="class_quant_lib_1_1_sobol_rsg.html#details">More...</a></p>

<p><code>#include &lt;ql/math/randomnumbers/sobolrsg.hpp&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:af5254f10d63ffdac50ac07c6df7cc90d"><td class="memItemLeft" align="right" valign="top"><a id="af5254f10d63ffdac50ac07c6df7cc90d"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><b>DirectionIntegers</b> { <br />
&#160;&#160;<b>Unit</b>, 
<b>Jaeckel</b>, 
<b>SobolLevitan</b>, 
<b>SobolLevitanLemieux</b>, 
<br />
&#160;&#160;<b>JoeKuoD5</b>, 
<b>JoeKuoD6</b>, 
<b>JoeKuoD7</b>, 
<b>Kuo</b>, 
<br />
&#160;&#160;<b>Kuo2</b>, 
<b>Kuo3</b>
<br />
 }</td></tr>
<tr class="separator:af5254f10d63ffdac50ac07c6df7cc90d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af3b59a3dd56521693efc68c221a2bf38"><td class="memItemLeft" align="right" valign="top"><a id="af3b59a3dd56521693efc68c221a2bf38"></a>
typedef <a class="el" href="struct_quant_lib_1_1_sample.html">Sample</a>&lt; std::vector&lt; <a class="el" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>sample_type</b></td></tr>
<tr class="separator:af3b59a3dd56521693efc68c221a2bf38"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a517494ec668ecd36efffc01912e484c0"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_sobol_rsg.html#a517494ec668ecd36efffc01912e484c0">SobolRsg</a> (<a class="el" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77">Size</a> dimensionality, unsigned long seed=0, DirectionIntegers directionIntegers=Jaeckel)</td></tr>
<tr class="separator:a517494ec668ecd36efffc01912e484c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7b9e11f498dab87a37a3cb75965e94c8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_sobol_rsg.html#a7b9e11f498dab87a37a3cb75965e94c8">skipTo</a> (boost::uint_least32_t n)</td></tr>
<tr class="separator:a7b9e11f498dab87a37a3cb75965e94c8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a77826ff84012851cc4abd1c217564cee"><td class="memItemLeft" align="right" valign="top"><a id="a77826ff84012851cc4abd1c217564cee"></a>
const std::vector&lt; boost::uint_least32_t &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>nextInt32Sequence</b> () const</td></tr>
<tr class="separator:a77826ff84012851cc4abd1c217564cee"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af099844672ae163c458ad6f0aafba9ae"><td class="memItemLeft" align="right" valign="top"><a id="af099844672ae163c458ad6f0aafba9ae"></a>
const <a class="el" href="struct_quant_lib_1_1_sample.html">SobolRsg::sample_type</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>nextSequence</b> () const</td></tr>
<tr class="separator:af099844672ae163c458ad6f0aafba9ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a21fb9bff0e8370796df2b4a9d16b372b"><td class="memItemLeft" align="right" valign="top"><a id="a21fb9bff0e8370796df2b4a9d16b372b"></a>
const <a class="el" href="struct_quant_lib_1_1_sample.html">sample_type</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>lastSequence</b> () const</td></tr>
<tr class="separator:a21fb9bff0e8370796df2b4a9d16b372b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d909a81181d49375588c96fd1494043"><td class="memItemLeft" align="right" valign="top"><a id="a6d909a81181d49375588c96fd1494043"></a>
<a class="el" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77">Size</a>&#160;</td><td class="memItemRight" valign="bottom"><b>dimension</b> () const</td></tr>
<tr class="separator:a6d909a81181d49375588c96fd1494043"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Sobol low-discrepancy sequence generator. </p>
<p>A Gray code counter and bitwise operations are used for very fast sequence generation.</p>
<p>The implementation relies on primitive polynomials modulo two from the book "Monte Carlo Methods in Finance" by Peter Jäckel.</p>
<p>21 200 primitive polynomials modulo two are provided in <a class="el" href="namespace_quant_lib.html">QuantLib</a>. Jäckel has calculated 8 129 334 polynomials: if you need that many dimensions you can replace the primitivepolynomials.cpp file included in <a class="el" href="namespace_quant_lib.html">QuantLib</a> with the one provided in the CD of the "Monte Carlo
Methods in Finance" book.</p>
<p>The choice of initialization numbers (also know as free direction integers) is crucial for the homogeneity properties of the sequence. Sobol defines two homogeneity properties: Property A and Property A'.</p>
<p>The unit initialization numbers suggested in "Numerical
Recipes in C", 2nd edition, by Press, Teukolsky, Vetterling, and Flannery (section 7.7) fail the test for Property A even for low dimensions.</p>
<p>Bratley and Fox published coefficients of the free direction integers up to dimension 40, crediting unpublished work of Sobol' and Levitan. See Bratley, P., Fox, B.L. (1988) "Algorithm 659: Implementing Sobol's quasirandom sequence
generator," ACM Transactions on Mathematical Software 14:88-100. These values satisfy Property A for d&lt;=20 and d = 23, 31, 33, 34, 37; Property A' holds for d&lt;=6.</p>
<p>Jäckel provides in his book (section 8.3) initialization numbers up to dimension 32. Coefficients for d&lt;=8 are the same as in Bradley-Fox, so Property A' holds for d&lt;=6 but Property A holds for d&lt;=32.</p>
<p>The implementation of Lemieux, Cieslak, and Luttmer includes coefficients of the free direction integers up to dimension</p><ol type="1">
<li>Coefficients for d&lt;=40 are the same as in Bradley-Fox. For dimension 40&lt;d&lt;=360 the coefficients have been calculated as optimal values based on the "resolution" criterion. See "RandQMC user's guide - A package for
randomized quasi-Monte Carlo methods in C," by C. Lemieux, M. Cieslak, and K. Luttmer, version January 13 2004, and references cited there (<a href="http://www.math.ucalgary.ca/~lemieux/randqmc.html">http://www.math.ucalgary.ca/~lemieux/randqmc.html</a>). The values up to d&lt;=360 has been provided to the <a class="el" href="namespace_quant_lib.html">QuantLib</a> team by Christiane Lemieux, private communication, September 2004.</li>
</ol>
<p>For more info on Sobol' sequences see also "Monte Carlo
Methods in Financial Engineering," by P. Glasserman, 2004, Springer, section 5.2.3</p>
<p>The Joe&ndash;Kuo numbers and the Kuo numbers are due to Stephen Joe and Frances Kuo.</p>
<p>S. Joe and F. Y. Kuo, Constructing Sobol sequences with better two-dimensional projections, preprint Nov 22 2007</p>
<p>See <a href="http://web.maths.unsw.edu.au/~fkuo/sobol/">http://web.maths.unsw.edu.au/~fkuo/sobol/</a> for more information.</p>
<p>The Joe-Kuo numbers are available under a BSD-style license available at the above link.</p>
<p>Note that the Kuo numbers were generated to work with a different ordering of primitive polynomials for the first 40 or so dimensions which is why we have the Alternative Primitive Polynomials.</p>
<dl class="test"><dt><b><a class="el" href="test.html#_test000067">Tests:</a></b></dt><dd><ul>
<li>the correctness of the returned values is tested by reproducing known good values.</li>
<li>the correctness of the returned values is tested by checking their discrepancy against known good values. </li>
</ul>
</dd></dl>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a517494ec668ecd36efffc01912e484c0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a517494ec668ecd36efffc01912e484c0">&#9670;&nbsp;</a></span>SobolRsg()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_quant_lib_1_1_sobol_rsg.html">SobolRsg</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77">Size</a>&#160;</td>
          <td class="paramname"><em>dimensionality</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>seed</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DirectionIntegers&#160;</td>
          <td class="paramname"><em>directionIntegers</em> = <code>Jaeckel</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="section pre"><dt>Precondition</dt><dd>dimensionality must be &lt;= PPMT_MAX_DIM </dd></dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a7b9e11f498dab87a37a3cb75965e94c8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7b9e11f498dab87a37a3cb75965e94c8">&#9670;&nbsp;</a></span>skipTo()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void skipTo </td>
          <td>(</td>
          <td class="paramtype">boost::uint_least32_t&#160;</td>
          <td class="paramname"><em>n</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>skip to the n-th sample in the low-discrepancy sequence </p>

</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="http://www.doxygen.org/index.html">Doxygen</a>
1.8.20
</small></address>
</body>
</html>