QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
experimental
credit
onefactorgaussiancopula.cpp
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) 2008 Roland Lichters
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
#include <
ql/experimental/credit/onefactorgaussiancopula.hpp
>
21
22
namespace
QuantLib
{
23
24
//-----------------------------------------------------------------------
25
Real
OneFactorGaussianCopula::testCumulativeY
(
Real
y
)
const
{
26
//-----------------------------------------------------------------------
27
Real
c =
correlation_
->value();
28
29
if
(c == 0)
30
return
CumulativeNormalDistribution
()(
y
);
31
32
if
(c == 1)
33
return
CumulativeNormalDistribution
()(
y
);
34
35
NormalDistribution
dz;
36
NormalDistribution
dm
;
37
38
Real
minimum = -10;
39
Real
maximum = +10;
40
int
steps
= 200;
41
42
Real
delta = (maximum - minimum) /
steps
;
43
Real
cumulated = 0;
44
if
(c < 0.5) {
45
// outer integral -> 1 for c -> 0
46
// inner integral -> CumulativeNormal()(y) for c-> 0
47
for
(
Real
m
= minimum;
m
< maximum;
m
+= delta)
48
for
(
Real
z = minimum; z < (
y
- std::sqrt(c) *
m
) / std::sqrt (1. - c);
49
z += delta)
50
cumulated +=
dm
(
m
) * dz (z);
51
}
52
else
{
53
// outer integral -> 1 for c -> 1
54
// inner integral -> CumulativeNormal()(y) for c-> 1
55
for
(
Real
z = minimum; z < maximum; z += delta)
56
for
(
Real
m
= minimum;
m
< (
y
- std::sqrt(1.0 - c) * z) / std::sqrt(c);
57
m
+= delta)
58
cumulated +=
dm
(
m
) * dz (z);
59
}
60
cumulated *= (delta * delta);
61
62
return
cumulated;
63
}
64
65
}
66
y
Real y
Definition:
andreasenhugevolatilityinterpl.cpp:46
QuantLib::CumulativeNormalDistribution
Cumulative normal distribution function.
Definition:
normaldistribution.hpp:68
QuantLib::NormalDistribution
Normal distribution function.
Definition:
normaldistribution.hpp:44
QuantLib::OneFactorCopula::dm
Real dm(Size i) const
Definition:
onefactorcopula.hpp:272
QuantLib::OneFactorCopula::correlation_
Handle< Quote > correlation_
Definition:
onefactorcopula.hpp:242
QuantLib::OneFactorCopula::m
Real m(Size i) const
Definition:
onefactorcopula.hpp:276
QuantLib::OneFactorCopula::steps
Size steps() const
Definition:
onefactorcopula.hpp:268
QuantLib::OneFactorGaussianCopula::testCumulativeY
Real testCumulativeY(Real y) const
Definition:
onefactorgaussiancopula.cpp:25
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib
Definition:
any.hpp:35
onefactorgaussiancopula.hpp
One-factor Gaussian copula.
Generated by
Doxygen
1.9.5