QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
distributions
bivariatenormaldistribution.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
Copyright (C) 2005 Gary Kennedy
6
7
This file is part of QuantLib, a free-software/open-source library
8
for financial quantitative analysts and developers - http://quantlib.org/
9
10
QuantLib is free software: you can redistribute it and/or modify it
11
under the terms of the QuantLib license. You should have received a
12
copy of the license along with this program; if not, please email
13
<quantlib-dev@lists.sf.net>. The license is also available online at
14
<http://quantlib.org/license.shtml>.
15
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the license for more details.
19
*/
20
21
/*! \file bivariatenormaldistribution.hpp
22
\brief bivariate cumulative normal distribution
23
*/
24
25
#ifndef quantlib_bivariatenormal_distribution_hpp
26
#define quantlib_bivariatenormal_distribution_hpp
27
28
#include <
ql/math/distributions/normaldistribution.hpp
>
29
30
namespace
QuantLib
{
31
32
//! Cumulative bivariate normal distribution function
33
/*! Drezner (1978) algorithm, six decimal places accuracy.
34
35
For this implementation see
36
"Option pricing formulas", E.G. Haug, McGraw-Hill 1998
37
38
\todo check accuracy of this algorithm and compare with:
39
1) Drezner, Z, (1978),
40
Computation of the bivariate normal integral,
41
Mathematics of Computation 32, pp. 277-279.
42
2) Drezner, Z. and Wesolowsky, G. O. (1990)
43
`On the Computation of the Bivariate Normal Integral',
44
Journal of Statistical Computation and Simulation 35,
45
pp. 101-107.
46
3) Drezner, Z (1992)
47
Computation of the Multivariate Normal Integral,
48
ACM Transactions on Mathematics Software 18, pp. 450-460.
49
4) Drezner, Z (1994)
50
Computation of the Trivariate Normal Integral,
51
Mathematics of Computation 62, pp. 289-294.
52
5) Genz, A. (1992)
53
`Numerical Computation of the Multivariate Normal
54
Probabilities', J. Comput. Graph. Stat. 1, pp. 141-150.
55
56
\test the correctness of the returned value is tested by
57
checking it against known good results.
58
*/
59
class
BivariateCumulativeNormalDistributionDr78
{
60
public
:
61
BivariateCumulativeNormalDistributionDr78
(
Real
rho
);
62
// function
63
Real
operator()
(
Real
a,
Real
b
)
const
;
64
private
:
65
Real
rho_
,
rho2_
;
66
static
const
Real
x_
[],
y_
[];
67
};
68
69
70
//! Cumulative bivariate normal distibution function (West 2004)
71
/*! The implementation derives from the article "Better
72
Approximations To Cumulative Normal Distibutions", Graeme
73
West, Dec 2004 available at www.finmod.co.za. Also available
74
in Wilmott Magazine, 2005, (May), 70-76, The main code is a
75
port of the C++ code at www.finmod.co.za/cumfunctions.zip.
76
77
The algorithm is based on the near double-precision algorithm
78
described in "Numerical Computation of Rectangular Bivariate
79
an Trivariate Normal and t Probabilities", Genz (2004),
80
Statistics and Computing 14, 151-160. (available at
81
www.sci.wsu.edu/math/faculty/henz/homepage)
82
83
The QuantLib implementation mainly differs from the original
84
code in two regards;
85
- The implementation of the cumulative normal distribution is
86
QuantLib::CumulativeNormalDistribution
87
- The arrays XX and W are zero-based
88
89
\test the correctness of the returned value is tested by
90
checking it against known good results.
91
*/
92
class
BivariateCumulativeNormalDistributionWe04DP
{
93
public
:
94
BivariateCumulativeNormalDistributionWe04DP
(
Real
rho
);
95
// function
96
Real
operator()
(
Real
a,
Real
b
)
const
;
97
private
:
98
Real
correlation_
;
99
CumulativeNormalDistribution
cumnorm_
;
100
};
101
102
//! default bivariate implementation
103
typedef
BivariateCumulativeNormalDistributionWe04DP
104
BivariateCumulativeNormalDistribution
;
105
106
}
107
108
109
#endif
QuantLib::BivariateCumulativeNormalDistributionDr78
Cumulative bivariate normal distribution function.
Definition:
bivariatenormaldistribution.hpp:59
QuantLib::BivariateCumulativeNormalDistributionDr78::x_
static const Real x_[]
Definition:
bivariatenormaldistribution.hpp:66
QuantLib::BivariateCumulativeNormalDistributionDr78::rho_
Real rho_
Definition:
bivariatenormaldistribution.hpp:65
QuantLib::BivariateCumulativeNormalDistributionDr78::y_
static const Real y_[]
Definition:
bivariatenormaldistribution.hpp:66
QuantLib::BivariateCumulativeNormalDistributionDr78::operator()
Real operator()(Real a, Real b) const
Definition:
bivariatenormaldistribution.cpp:56
QuantLib::BivariateCumulativeNormalDistributionDr78::rho2_
Real rho2_
Definition:
bivariatenormaldistribution.hpp:65
QuantLib::BivariateCumulativeNormalDistributionWe04DP
Cumulative bivariate normal distibution function (West 2004)
Definition:
bivariatenormaldistribution.hpp:92
QuantLib::BivariateCumulativeNormalDistributionWe04DP::cumnorm_
CumulativeNormalDistribution cumnorm_
Definition:
bivariatenormaldistribution.hpp:99
QuantLib::BivariateCumulativeNormalDistributionWe04DP::correlation_
Real correlation_
Definition:
bivariatenormaldistribution.hpp:98
QuantLib::BivariateCumulativeNormalDistributionWe04DP::operator()
Real operator()(Real a, Real b) const
Definition:
bivariatenormaldistribution.cpp:165
QuantLib::CumulativeNormalDistribution
Cumulative normal distribution function.
Definition:
normaldistribution.hpp:68
b
ext::function< Real(Real)> b
Definition:
extendedornsteinuhlenbeckprocess.cpp:30
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
rho
Real rho
Definition:
hestonrndcalculator.cpp:36
QuantLib
Definition:
any.hpp:35
QuantLib::BivariateCumulativeNormalDistribution
BivariateCumulativeNormalDistributionWe04DP BivariateCumulativeNormalDistribution
default bivariate implementation
Definition:
bivariatenormaldistribution.hpp:104
normaldistribution.hpp
normal, cumulative and inverse cumulative distributions
Generated by
Doxygen
1.9.5