QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
onefactorstudentcopula.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) 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/*! \file onefactorstudentcopula.hpp
21 \brief One-factor Student-t copula
22*/
23
24#ifndef quantlib_one_factor_student_copula_hpp
25#define quantlib_one_factor_student_copula_hpp
26
30
31namespace QuantLib {
32
33 //! One-factor Double Student t-Copula
34 /*! The copula model
35 \f[ Y_i = a_i\,M+\sqrt{1-a_i^2}\:Z_i \f]
36
37 is specified here by setting the probability density functions
38 for \f$ Z_i \f$ (\f$ D_Z \f$) and \f$ M \f$ (\f$ D_M \f$) to
39 Student t-distributions with \f$ N_z \f$ and \f$ N_m \f$
40 degrees of freedom, respectively.
41
42 The variance of the Student t-distribution with \f$ \nu \f$
43 degrees of freedom is \f$ \nu / (\nu - 2) \f$. Since the
44 copula approach requires zero mean and unit variance
45 distributions, variables \f$ Z \f$ and \f$ M \f$ are scaled by
46 \f$ \sqrt{(N_z - 2) / N_z} \f$ and \f$ \sqrt{(N_m - 2) / N_m}, \f$
47 respectively.
48
49 \todo Improve performance/accuracy of the calculation of
50 inverse cumulative Y. Tabulate and store it for selected
51 correlations?
52 */
54 public:
56 int nz, int nm,
57 Real maximum = 10, Size integrationSteps = 200);
58
59 Real density(Real m) const override;
60 Real cumulativeZ(Real z) const override;
61
62 private:
63 //! Observer interface
64 void performCalculations() const override;
65
67 CumulativeStudentDistribution cumulative_; // cumulated density of Z
68 int nz_; // degrees of freedom of Z
69 int nm_; // degrees of freedom of M
70
71 Real scaleM_; // scaling for m to ensure unit variance
72 Real scaleZ_; // scaling for z to ensure unit variance
73
74 // This function is used to update the table of the cumulative
75 // distribution of Y. It is invoked by performCalculations() when the
76 // correlation handle is amended.
78 };
79
81 return density_(m / scaleM_) / scaleM_;
82 }
83
85 return cumulative_(z / scaleZ_);
86 }
87
88
89 //! One-factor Gaussian-Student t-Copula
90 /*! The copula model
91 \f[ Y_i = a_i\,M+\sqrt{1-a_i^2}\:Z_i \f]
92
93 is specified here by setting the probability density functions
94 for \f$ Z_i \f$ (\f$ D_Z \f$) to a Student t-distributions
95 with \f$ N_z \f$ degrees of freedom, and for \f$ M \f$
96 (\f$ D_M \f$) to a Gaussian.
97
98 The variance of the Student t-distribution with \f$ \nu \f$
99 degrees of freedom is \f$ \nu / (\nu - 2) \f$. Since the
100 copula approach requires zero mean and unit variance
101 distributions, \f$ Z \f$ is scaled by \f$ \sqrt{(N_z - 2) /
102 N_z}.\f$
103
104 \todo Improve performance/accuracy of the calculation of
105 inverse cumulative Y. Tabulate and store it for selected
106 correlations?
107 */
109 public:
111 int nz,
112 Real maximum = 10,
113 Size integrationSteps = 200);
114
115 Real density(Real m) const override;
116 Real cumulativeZ(Real z) const override;
117
118 private:
119 //! Observer interface
120 void performCalculations() const override;
121
124 int nz_; // degrees of freedom of Z
125
126 Real scaleZ_; // scaling for z to ensure unit variance
127
128 // This function is used to update the table of the cumulative
129 // distribution of Y. It is invoked by performCalculations() when the
130 // correlation handle is amended.
132 };
133
135 return density_(m);
136 }
137
139 return cumulative_(z / scaleZ_);
140 }
141
142
143 //! One-factor Student t - Gaussian Copula
144 /*! The copula model
145 \f[ Y_i = a_i\,M+\sqrt{1-a_i^2}\:Z_i \f]
146 is specified here by setting the probability density functions
147 for \f$ Z_i \f$ (\f$ D_Z \f$) to a Gaussian and for \f$ M \f$
148 (\f$ D_M \f$) to a Student t-distribution with \f$ N_m \f$
149 degrees of freedom.
150
151 The variance of the Student t-distribution with \f$ \nu \f$
152 degrees of freedom is \f$ \nu / (\nu - 2) \f$. Since the
153 copula approach requires zero mean and unit variance
154 distributions, \f$ M \f$ is scaled by \f$ \sqrt{(N_m - 2) /
155 N_m}. \f$
156
157 \todo Improve performance/accuracy of the calculation of
158 inverse cumulative Y. Tabulate and store it for selected
159 correlations?
160 */
162 public:
164 int nm,
165 Real maximum = 10,
166 Size integrationSteps = 200);
167
168 Real density(Real m) const override;
169 Real cumulativeZ(Real z) const override;
170
171 private:
172 //! Observer interface
173 void performCalculations() const override;
174
176 CumulativeNormalDistribution cumulative_; // cumulated density of Z
177 int nm_; // degrees of freedom of M
178
179 Real scaleM_; // scaling for m to ensure unit variance
180
181 // This function is used to update the table of the cumulative
182 // distribution of Y. It is invoked by performCalculations() when the
183 // correlation handle is amended.
185 };
186
188 return density_(m / scaleM_) / scaleM_;
189 }
190
192 return cumulative_(z);
193 }
194
195}
196
197
198#endif
Cumulative normal distribution function.
Cumulative Student t-distribution.
Shared handle to an observable.
Definition: handle.hpp:41
Normal distribution function.
Abstract base class for one-factor copula models.
Real correlation() const
Single correlation parameter.
One-factor Gaussian-Student t-Copula.
void performCalculations() const override
Observer interface.
Real density(Real m) const override
Density function of M.
Real cumulativeZ(Real z) const override
Cumulative distribution of Z.
One-factor Double Student t-Copula.
void performCalculations() const override
Observer interface.
Real density(Real m) const override
Density function of M.
Real cumulativeZ(Real z) const override
Cumulative distribution of Z.
CumulativeStudentDistribution cumulative_
One-factor Student t - Gaussian Copula.
void performCalculations() const override
Observer interface.
Real density(Real m) const override
Density function of M.
Real cumulativeZ(Real z) const override
Cumulative distribution of Z.
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
normal, cumulative and inverse cumulative distributions
One-factor copula base class.
Student's t-distribution.