QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
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
29
30namespace 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 */
60 public:
62 // function
63 Real operator()(Real a, Real b) const;
64 private:
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 */
93 public:
95 // function
96 Real operator()(Real a, Real b) const;
97 private:
100 };
101
102 //! default bivariate implementation
105
106}
107
108
109#endif
Cumulative bivariate normal distribution function.
Cumulative bivariate normal distibution function (West 2004)
Cumulative normal distribution function.
ext::function< Real(Real)> b
QL_REAL Real
real number
Definition: types.hpp:50
Real rho
Definition: any.hpp:35
BivariateCumulativeNormalDistributionWe04DP BivariateCumulativeNormalDistribution
default bivariate implementation
normal, cumulative and inverse cumulative distributions