File: _latent_model_8cpp-example.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 (393 lines) | stat: -rw-r--r-- 35,164 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<!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: LatentModel.cpp</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>
</div><!-- top -->
<!-- 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 class="header">
  <div class="headertitle">
<div class="title">LatentModel.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>This example shows the calculation of correlated defaults.</p>
<div class="fragment"><div class="line"><span class="comment">/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> Copyright (C) 2014 Jose Aparicio</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> This file is part of QuantLib, a free-software/open-source library</span></div>
<div class="line"><span class="comment"> for financial quantitative analysts and developers - http://quantlib.org/</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> QuantLib is free software: you can redistribute it and/or modify it</span></div>
<div class="line"><span class="comment"> under the terms of the QuantLib license.  You should have received a</span></div>
<div class="line"><span class="comment"> copy of the license along with this program; if not, please email</span></div>
<div class="line"><span class="comment"> &lt;quantlib-dev@lists.sf.net&gt;. The license is also available online at</span></div>
<div class="line"><span class="comment"> &lt;http://quantlib.org/license.shtml&gt;.</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> This program is distributed in the hope that it will be useful, but WITHOUT</span></div>
<div class="line"><span class="comment"> ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span></div>
<div class="line"><span class="comment"> FOR A PARTICULAR PURPOSE.  See the license for more details.</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;ql/qldefines.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#ifdef BOOST_MSVC</span></div>
<div class="line"><span class="preprocessor">#  include &lt;ql/auto_link.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/experimental/credit/randomdefaultlatentmodel.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/termstructures/credit/flathazardrate.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/currencies/europe.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/time/calendars/target.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/time/daycounters/actual365fixed.hpp&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keyword">using namespace </span><a class="code" href="namespace_quant_lib.html">QuantLib</a>;</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(QL_ENABLE_SESSIONS)</span></div>
<div class="line"><span class="keyword">namespace </span><a class="code" href="namespace_quant_lib.html">QuantLib</a> {</div>
<div class="line"> </div>
<div class="line">    ThreadKey sessionId() { <span class="keywordflow">return</span> 0; }</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">/* This sample code shows basic usage of a Latent variable model.</span></div>
<div class="line"><span class="comment">   The data and correlation problem presented is the same as in:</span></div>
<div class="line"><span class="comment">     &#39;Modelling Dependent Defaults: Asset Correlations Are Not Enough!&#39;</span></div>
<div class="line"><span class="comment">     Frey R., A. J. McNeil and M. A. Nyfeler RiskLab publications March 2001</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span>, <span class="keywordtype">char</span>* []) {</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">try</span> {</div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <a name="_a0"></a><a class="code" href="class_quant_lib_1_1_calendar.html" title="calendar class">Calendar</a> calendar = <a name="_a1"></a><a class="code" href="class_quant_lib_1_1_t_a_r_g_e_t.html" title="TARGET calendar">TARGET</a>();</div>
<div class="line">        <a name="_a2"></a><a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> todaysDate(19, March, 2014);</div>
<div class="line">        <span class="comment">// must be a business day</span></div>
<div class="line">        todaysDate = calendar.<a name="a3"></a><a class="code" href="class_quant_lib_1_1_calendar.html#a712629806d9ef9a39f8144f368c81e4b">adjust</a>(todaysDate);</div>
<div class="line"> </div>
<div class="line">        Settings::instance().evaluationDate() = todaysDate;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">        <span class="comment">/* --------------------------------------------------------------</span></div>
<div class="line"><span class="comment">                        SET UP BASKET PORTFOLIO</span></div>
<div class="line"><span class="comment">        -------------------------------------------------------------- */</span></div>
<div class="line">        <span class="comment">// build curves and issuers into a basket of three names</span></div>
<div class="line">        std::vector&lt;Real&gt; hazardRates(3, -std::log(1.-0.01));</div>
<div class="line">        std::vector&lt;std::string&gt; names;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;hazardRates.size(); i++)</div>
<div class="line">            names.push_back(std::string(<span class="stringliteral">&quot;Acme&quot;</span>) + </div>
<div class="line">                boost::lexical_cast&lt;std::string&gt;(i));</div>
<div class="line">        std::vector&lt;Handle&lt;DefaultProbabilityTermStructure&gt; &gt; defTS;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;hazardRates.size(); i++)</div>
<div class="line">            defTS.push_back(<a name="_a4"></a><a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;DefaultProbabilityTermStructure&gt;</a>(</div>
<div class="line">                ext::make_shared&lt;FlatHazardRate&gt;(0, <a class="code" href="class_quant_lib_1_1_t_a_r_g_e_t.html" title="TARGET calendar">TARGET</a>(), hazardRates[i], </div>
<div class="line">                    <a name="_a5"></a><a class="code" href="class_quant_lib_1_1_actual365_fixed.html" title="Actual/365 (Fixed) day count convention.">Actual365Fixed</a>())));</div>
<div class="line">        std::vector&lt;Issuer&gt; issuers;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;hazardRates.size(); i++) {</div>
<div class="line">            std::vector&lt;QuantLib::Issuer::key_curve_pair&gt; curves(1, </div>
<div class="line">                std::make_pair(<a name="_a6"></a><a class="code" href="class_quant_lib_1_1_north_america_corp_default_key.html" title="ISDA standard default contractual key for corporate US debt.">NorthAmericaCorpDefaultKey</a>(</div>
<div class="line">                    <a name="_a7"></a><a class="code" href="class_quant_lib_1_1_e_u_r_currency.html" title="European Euro.">EURCurrency</a>(), QuantLib::SeniorSec,</div>
<div class="line">                    <a name="_a8"></a><a class="code" href="class_quant_lib_1_1_period.html">Period</a>(), 1. <span class="comment">// amount threshold</span></div>
<div class="line">                    ), defTS[i]));</div>
<div class="line">            issuers.push_back(Issuer(curves));</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        ext::shared_ptr&lt;Pool&gt; thePool = ext::make_shared&lt;Pool&gt;();</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;hazardRates.size(); i++)</div>
<div class="line">            thePool-&gt;add(names[i], issuers[i], <a class="code" href="class_quant_lib_1_1_north_america_corp_default_key.html" title="ISDA standard default contractual key for corporate US debt.">NorthAmericaCorpDefaultKey</a>(</div>
<div class="line">                    <a class="code" href="class_quant_lib_1_1_e_u_r_currency.html" title="European Euro.">EURCurrency</a>(), QuantLib::SeniorSec, <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(), 1.));</div>
<div class="line"> </div>
<div class="line">        std::vector&lt;DefaultProbKey&gt; defaultKeys(hazardRates.size(), </div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_north_america_corp_default_key.html" title="ISDA standard default contractual key for corporate US debt.">NorthAmericaCorpDefaultKey</a>(<a class="code" href="class_quant_lib_1_1_e_u_r_currency.html" title="European Euro.">EURCurrency</a>(), SeniorSec, <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(), 1.));</div>
<div class="line">        <span class="comment">// Recoveries are irrelevant in this example but must be given as the </span></div>
<div class="line">        <span class="comment">//   lib stands.</span></div>
<div class="line">        std::vector&lt;ext::shared_ptr&lt;RecoveryRateModel&gt; &gt; rrModels(</div>
<div class="line">            hazardRates.size(), ext::make_shared&lt;ConstantRecoveryModel&gt;(</div>
<div class="line">            <a name="_a9"></a><a class="code" href="class_quant_lib_1_1_constant_recovery_model.html">ConstantRecoveryModel</a>(0.5, SeniorSec)));</div>
<div class="line">        ext::shared_ptr&lt;Basket&gt; theBskt = ext::make_shared&lt;Basket&gt;(</div>
<div class="line">            todaysDate, names, std::vector&lt;Real&gt;(hazardRates.size(), 100.), </div>
<div class="line">            thePool);</div>
<div class="line">        <span class="comment">/* --------------------------------------------------------------</span></div>
<div class="line"><span class="comment">                        SET UP JOINT DEFAULT EVENT LATENT MODELS</span></div>
<div class="line"><span class="comment">        -------------------------------------------------------------- */</span></div>
<div class="line">        <span class="comment">// Latent model factors, corresponds to the first entry in Table1 of the</span></div>
<div class="line">        <span class="comment">//   publication mentioned. It is a single factor model</span></div>
<div class="line">        std::vector&lt;std::vector&lt;Real&gt; &gt; fctrsWeights(hazardRates.size(), </div>
<div class="line">            std::vector&lt;Real&gt;(1, std::sqrt(0.1)));</div>
<div class="line">        <span class="comment">// --- Default Latent models -------------------------------------</span></div>
<div class="line"><span class="preprocessor">        #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">        <span class="comment">// Gaussian integrable joint default model:</span></div>
<div class="line">        ext::shared_ptr&lt;GaussianDefProbLM&gt; lmG(<span class="keyword">new</span> </div>
<div class="line">            <a name="_a10"></a><a class="code" href="class_quant_lib_1_1_default_latent_model.html" title="Default event Latent Model.">GaussianDefProbLM</a>(fctrsWeights, </div>
<div class="line">            LatentModelIntegrationType::GaussianQuadrature,</div>
<div class="line">            GaussianCopulaPolicy::initTraits() <span class="comment">// otherwise gcc screams</span></div>
<div class="line">            ));</div>
<div class="line"><span class="preprocessor">        #endif</span></div>
<div class="line">        <span class="comment">// Define StudentT copula</span></div>
<div class="line">        <span class="comment">// this is as far as we can be from the Gaussian, 2 T_3 factors:</span></div>
<div class="line">        std::vector&lt;Integer&gt; ordersT(2, 3);</div>
<div class="line">        <a name="_a11"></a><a class="code" href="struct_quant_lib_1_1_t_copula_policy_1_1init_traits.html">TCopulaPolicy::initTraits</a> iniT;</div>
<div class="line">        iniT.<a name="a12"></a>tOrders = ordersT;</div>
<div class="line">        <span class="comment">// StudentT integrable joint default model:</span></div>
<div class="line">        ext::shared_ptr&lt;TDefProbLM&gt; lmT(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_default_latent_model.html" title="Default event Latent Model.">TDefProbLM</a>(fctrsWeights, </div>
<div class="line">            <span class="comment">// LatentModelIntegrationType::GaussianQuadrature,</span></div>
<div class="line">            LatentModelIntegrationType::Trapezoid,</div>
<div class="line">            iniT));</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// --- Default Loss models ----------------------------------------</span></div>
<div class="line">        <span class="comment">// Gaussian random joint default model:</span></div>
<div class="line">        <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numSimulations = 100000;</div>
<div class="line">        <span class="comment">// Size numCoresUsed = 4;</span></div>
<div class="line"><span class="preprocessor">        #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">        <span class="comment">// Sobol, many cores</span></div>
<div class="line">        ext::shared_ptr&lt;DefaultLossModel&gt; rdlmG(</div>
<div class="line">            ext::make_shared&lt;<a name="_a13"></a><a class="code" href="class_quant_lib_1_1_random_default_l_m.html">RandomDefaultLM&lt;GaussianCopulaPolicy&gt;</a> &gt;(lmG, </div>
<div class="line">                std::vector&lt;Real&gt;(), numSimulations, 1.e-6, 2863311530UL));</div>
<div class="line"><span class="preprocessor">        #endif</span></div>
<div class="line">        <span class="comment">// StudentT random joint default model:</span></div>
<div class="line">        ext::shared_ptr&lt;DefaultLossModel&gt; rdlmT(</div>
<div class="line">            ext::make_shared&lt;<a class="code" href="class_quant_lib_1_1_random_default_l_m.html">RandomDefaultLM&lt;TCopulaPolicy&gt;</a> &gt;(lmT, </div>
<div class="line">            std::vector&lt;Real&gt;(), numSimulations, 1.e-6, 2863311530UL));</div>
<div class="line"> </div>
<div class="line">        <span class="comment">/* --------------------------------------------------------------</span></div>
<div class="line"><span class="comment">                        DUMP SOME RESULTS</span></div>
<div class="line"><span class="comment">        -------------------------------------------------------------- */</span></div>
<div class="line">        <span class="comment">/* Default correlations in a T copula should be below those of the </span></div>
<div class="line"><span class="comment">        gaussian for the same factors.</span></div>
<div class="line"><span class="comment">        The calculations on the MC show dispersion on both copulas (thats</span></div>
<div class="line"><span class="comment">        ok) and too large values with very large dispersions on the T case.</span></div>
<div class="line"><span class="comment">        Computations are ok, within the dispersion, for the gaussian; compare</span></div>
<div class="line"><span class="comment">        with the direct integration in both cases.</span></div>
<div class="line"><span class="comment">        However the T does converge to the gaussian value for large value of</span></div>
<div class="line"><span class="comment">        the parameters.</span></div>
<div class="line"><span class="comment">        */</span></div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> calcDate(<a class="code" href="class_quant_lib_1_1_t_a_r_g_e_t.html" title="TARGET calendar">TARGET</a>().advance(Settings::instance().evaluationDate(), </div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(120, Months)));</div>
<div class="line">        std::vector&lt;Probability&gt; probEventsTLatent, probEventsTRandLoss;</div>
<div class="line"><span class="preprocessor">        #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">        std::vector&lt;Probability&gt; probEventsGLatent, probEventsGRandLoss;</div>
<div class="line"><span class="preprocessor">        #endif</span></div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        lmT-&gt;resetBasket(theBskt);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numEvts=0; numEvts &lt;=theBskt-&gt;size(); numEvts++) {</div>
<div class="line">            probEventsTLatent.push_back(lmT-&gt;probAtLeastNEvents(numEvts, </div>
<div class="line">                calcDate));</div>
<div class="line">         }</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        theBskt-&gt;setLossModel(rdlmT);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numEvts=0; numEvts &lt;=theBskt-&gt;size(); numEvts++) {</div>
<div class="line">            probEventsTRandLoss.push_back(theBskt-&gt;probAtLeastNEvents(numEvts, </div>
<div class="line">                calcDate));</div>
<div class="line">         }</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line"><span class="preprocessor">        #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">        lmG-&gt;resetBasket(theBskt);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numEvts=0; numEvts &lt;=theBskt-&gt;size(); numEvts++) {</div>
<div class="line">            probEventsGLatent.push_back(lmG-&gt;probAtLeastNEvents(numEvts, </div>
<div class="line">                calcDate));</div>
<div class="line">         }</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        theBskt-&gt;setLossModel(rdlmG);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numEvts=0; numEvts &lt;=theBskt-&gt;size(); numEvts++) {</div>
<div class="line">            probEventsGRandLoss.push_back(theBskt-&gt;probAtLeastNEvents(numEvts, </div>
<div class="line">                calcDate));</div>
<div class="line">         }</div>
<div class="line"><span class="preprocessor">        #endif</span></div>
<div class="line"> </div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> correlDate = <a class="code" href="class_quant_lib_1_1_t_a_r_g_e_t.html" title="TARGET calendar">TARGET</a>().<a name="a14"></a><a class="code" href="class_quant_lib_1_1_calendar.html#ab3fc4d2c4ba5243c3f5d51dcb3077ceb">advance</a>(</div>
<div class="line">            Settings::instance().evaluationDate(), <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(12, Months));</div>
<div class="line">        std::vector&lt;std::vector&lt;Real&gt; &gt; correlsGlm, correlsTlm, correlsGrand, </div>
<div class="line">            correlsTrand;</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        lmT-&gt;resetBasket(theBskt);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            std::vector&lt;Real&gt; tmp;</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                tmp.push_back(lmT-&gt;defaultCorrelation(correlDate, </div>
<div class="line">                    iName1, iName2));</div>
<div class="line">            correlsTlm.push_back(tmp);</div>
<div class="line">        }</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        theBskt-&gt;setLossModel(rdlmT);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            std::vector&lt;Real&gt; tmp;</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                tmp.push_back(theBskt-&gt;defaultCorrelation(correlDate, </div>
<div class="line">                    iName1, iName2));</div>
<div class="line">            correlsTrand.push_back(tmp);</div>
<div class="line">        }</div>
<div class="line"><span class="preprocessor">        #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        lmG-&gt;resetBasket(theBskt);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            std::vector&lt;Real&gt; tmp;</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                tmp.push_back(lmG-&gt;defaultCorrelation(correlDate, </div>
<div class="line">                    iName1, iName2));</div>
<div class="line">            correlsGlm.push_back(tmp);</div>
<div class="line">        }</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        theBskt-&gt;setLossModel(rdlmG);</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            std::vector&lt;Real&gt; tmp;</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                tmp.push_back(theBskt-&gt;defaultCorrelation(correlDate, </div>
<div class="line">                    iName1, iName2));</div>
<div class="line">            correlsGrand.push_back(tmp);</div>
<div class="line">        }</div>
<div class="line"><span class="preprocessor">        #endif</span></div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; </div>
<div class="line">            <span class="stringliteral">&quot; Gaussian versus T prob of extreme event (random and integrable)-&quot;</span> </div>
<div class="line">            &lt;&lt; std::endl;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numEvts=0; numEvts &lt;=theBskt-&gt;size(); numEvts++) {</div>
<div class="line">            std::cout &lt;&lt; <span class="stringliteral">&quot;-Prob of &quot;</span> &lt;&lt; numEvts &lt;&lt; <span class="stringliteral">&quot; events... &quot;</span> &lt;&lt;</div>
<div class="line"><span class="preprocessor">                #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">                probEventsGLatent[numEvts] &lt;&lt; <span class="stringliteral">&quot; ** &quot;</span> &lt;&lt;</div>
<div class="line"><span class="preprocessor">                #else</span></div>
<div class="line">                <span class="stringliteral">&quot;n/a&quot;</span> &lt;&lt; <span class="stringliteral">&quot; ** &quot;</span> &lt;&lt;</div>
<div class="line"><span class="preprocessor">                #endif</span></div>
<div class="line">                probEventsTLatent[numEvts] &lt;&lt; <span class="stringliteral">&quot; ** &quot;</span> &lt;&lt; </div>
<div class="line"><span class="preprocessor">                #ifndef QL_PATCH_SOLARIS</span></div>
<div class="line">                probEventsGRandLoss[numEvts]&lt;&lt; <span class="stringliteral">&quot; ** &quot;</span> &lt;&lt;</div>
<div class="line"><span class="preprocessor">                #else</span></div>
<div class="line">                <span class="stringliteral">&quot;n/a&quot;</span> &lt;&lt; <span class="stringliteral">&quot; ** &quot;</span> &lt;&lt;</div>
<div class="line"><span class="preprocessor">                #endif</span></div>
<div class="line">                probEventsTRandLoss[numEvts] </div>
<div class="line">            &lt;&lt; std::endl;</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        cout &lt;&lt; endl;</div>
<div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;-- Default correlations G,T,GRand,TRand--&quot;</span> &lt;&lt; endl;</div>
<div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;-----------------------------------------&quot;</span> &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                cout &lt;&lt; </div>
<div class="line">                #ifndef QL_PATCH_SOLARIS</div>
<div class="line">                    correlsGlm[iName1][iName2] &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line"><span class="preprocessor">                #else</span></div>
<div class="line">                    <span class="stringliteral">&quot;n/a&quot;</span> &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line"><span class="preprocessor">                #endif</span></div>
<div class="line">            cout &lt;&lt; endl;</div>
<div class="line">        }</div>
<div class="line">        cout &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                cout &lt;&lt; </div>
<div class="line">                    correlsTlm[iName1][iName2] &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line">            ;</div>
<div class="line">                cout &lt;&lt; endl;</div>
<div class="line">        }</div>
<div class="line">        cout &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                cout &lt;&lt; </div>
<div class="line">                #ifndef QL_PATCH_SOLARIS</div>
<div class="line">                    correlsGrand[iName1][iName2] &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line"><span class="preprocessor">                #else</span></div>
<div class="line">                    <span class="stringliteral">&quot;n/a&quot;</span> &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line"><span class="preprocessor">                #endif</span></div>
<div class="line">            cout &lt;&lt; endl;</div>
<div class="line">        }</div>
<div class="line">        cout &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName1=0; iName1 &lt;theBskt-&gt;size(); iName1++) {</div>
<div class="line">            <span class="keywordflow">for</span>(<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> iName2=0; iName2 &lt;theBskt-&gt;size(); iName2++)</div>
<div class="line">                cout &lt;&lt; </div>
<div class="line">                    correlsTrand[iName1][iName2] &lt;&lt; <span class="stringliteral">&quot; , &quot;</span>;</div>
<div class="line">            ;</div>
<div class="line">                cout &lt;&lt; endl;</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">return</span> 0;</div>
<div class="line">    } <span class="keywordflow">catch</span> (exception&amp; e) {</div>
<div class="line">        cerr &lt;&lt; e.what() &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">return</span> 1;</div>
<div class="line">    } <span class="keywordflow">catch</span> (...) {</div>
<div class="line">        cerr &lt;&lt; <span class="stringliteral">&quot;unknown error&quot;</span> &lt;&lt; endl;</div>
<div class="line">        <span class="keywordflow">return</span> 1;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
</div><!-- fragment --> </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>