QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
CumulativeBehrensFisher Class Reference

Cumulative (generalized) BehrensFisher distribution. More...

#include <ql/experimental/math/convolvedstudentt.hpp>

+ Collaboration diagram for CumulativeBehrensFisher:

Public Member Functions

 CumulativeBehrensFisher (const std::vector< Integer > &degreesFreedom=std::vector< Integer >(), const std::vector< Real > &factors=std::vector< Real >())
 
const std::vector< Integer > & degreeFreedom () const
 Degrees of freedom of the Ts involved in the convolution. More...
 
const std::vector< Real > & factors () const
 Factors in the linear combination. More...
 
Probability operator() (Real x) const
 Returns the cumulative probability of the resulting distribution. More...
 
Probability density (Real x) const
 Returns the probability density of the resulting distribution. More...
 

Public Attributes

QL_DEPRECATED typedef Probability result_type
 
QL_DEPRECATED typedef Real argument_type
 

Private Member Functions

std::vector< RealpolynCharactT (Natural n) const
 Student t characteristic polynomials. More...
 
std::vector< RealconvolveVectorPolynomials (const std::vector< Real > &v1, const std::vector< Real > &v2) const
 

Private Attributes

std::vector< IntegerdegreesFreedom_
 
std::vector< Realfactors_
 
std::vector< std::vector< Real > > polynCharFnc_
 
std::vector< RealpolyConvolved_
 
Real a_ = 0.
 
Real a2_
 

Detailed Description

Cumulative (generalized) BehrensFisher distribution.

Exact analitical computation of the cumulative probability distribution of the linear combination of an arbitrary number (not just two) of T random variables of odd integer order. Adapted from the algorithm in:

V. Witkovsky, Journal of Statistical Planning and Inference 94 (2001) 1-13
see also:
On the distribution of a linear combination of t-distributed variables; Glenn Alan Walker, Ph.D.thesis University of Florida 1977
'Convolutions of the T Distribution'; S. Nadarajah, D. K. Dey in Computers and Mathematics with Applications 49 (2005) 715-721
The last reference provides direct expressions for some of the densities when the linear combination of only two Ts is just an addition. It can be used for testing the results here.
Another available test on this algorithm stems from the realization that a linear convex ( \( \sum a_i=1\)) combination of Ts of order one is stable in the distribution sense (but this result is often of no practical use because of its non-finite variance).
This implementation is for two or more T variables in the linear combination albeit these must be of odd order. The case of exactly two T of odd order is known to be a finite mixture of Ts but that result is not used here. On this line see 'Linearization coefficients of Bessel polynomials' C.Berg, C.Vignat; February 2008; arXiv:math/0506458
\todo Implement the series expansion solution for the addition of
two Ts of even order described in: 'On the density of the sum of two
independent Student t-random vectors' C.Berg, C.Vignat; June 2009;
eprint arXiv:0906.3037

Definition at line 60 of file convolvedstudentt.hpp.

Constructor & Destructor Documentation

◆ CumulativeBehrensFisher()

CumulativeBehrensFisher ( const std::vector< Integer > &  degreesFreedom = std::vector<Integer>(),
const std::vector< Real > &  factors = std::vector<Real>() 
)
Parameters
degreesFreedomDegrees of freedom of the Ts convolved. The algorithm is limited to odd orders only.
factorsFactors in the linear combination of the Ts.

Definition at line 30 of file convolvedstudentt.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ degreeFreedom()

const std::vector< Integer > & degreeFreedom ( ) const

Degrees of freedom of the Ts involved in the convolution.

Definition at line 83 of file convolvedstudentt.hpp.

◆ factors()

const std::vector< Real > & factors ( ) const

Factors in the linear combination.

Definition at line 87 of file convolvedstudentt.hpp.

+ Here is the caller graph for this function:

◆ polynCharactT()

std::vector< Real > polynCharactT ( Natural  n) const
private

Student t characteristic polynomials.

Generates the polynomial coefficients defining the characteristic function of a T distribution \(T_\nu\) of odd order; \(\nu=2n+1\). In general the characteristic function is given by:

\[ \phi_{\nu}(t) = \varphi_{n}(t) \exp{-\nu^{1/2}|t|} ;\,where\,\nu = 2n+1 \]

where \( \varphi \) are polynomials that are computed recursively.

The convolved characteristic function is the product of the two previous characteristic functions and the problem is then the convolution (a product) of two polynomials.

@param n Natural number defining the order of the T for which
the characteristic function is to be computed. The order of the
 T is then \f$ \nu=2n+1 \f$

Definition at line 72 of file convolvedstudentt.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convolveVectorPolynomials()

std::vector< Real > convolveVectorPolynomials ( const std::vector< Real > &  v1,
const std::vector< Real > &  v2 
) const
private

Definition at line 94 of file convolvedstudentt.cpp.

+ Here is the caller graph for this function:

◆ operator()()

Probability operator() ( Real  x) const

Returns the cumulative probability of the resulting distribution.

To obtain the cumulative probability the Gil-Pelaez theorem is applied:
First compute the characteristic function of the linear combination variable by multiplying the individual characteristic functions. Then transform back integrating the characteristic function according to the GP theorem; this is done here analytically feeding in the expression of the total characteristic function this:

\[ \int_0^{\infty}x^n e^{-ax}sin(bx)dx = (-1)^n \Gamma(n+1) \frac{sin((n+1)arctg2(-b/a))} {(\sqrt{a^2+b^2})^{n+1}}; for\,a>0,\,b>0 \]

and for the first term I use:

\[ \int_0^{\infty} \frac{e^{-ax}sin(bx)}{x} dx = arctg2(b/a) \]

The GP complex integration is simplified thanks to the symetry of the distribution.

Definition at line 115 of file convolvedstudentt.cpp.

+ Here is the call graph for this function:

◆ density()

Probability density ( Real  x) const

Returns the probability density of the resulting distribution.

Similarly to the cumulative probability, Gil-Pelaez theorem is applied, the integration is similar.

Definition at line 133 of file convolvedstudentt.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ result_type

QL_DEPRECATED typedef Probability result_type
Deprecated:
Use auto or decltype instead. Deprecated in version 1.29.

Definition at line 66 of file convolvedstudentt.hpp.

◆ argument_type

QL_DEPRECATED typedef Real argument_type
Deprecated:
Use auto or decltype instead. Deprecated in version 1.29.

Definition at line 72 of file convolvedstudentt.hpp.

◆ degreesFreedom_

std::vector<Integer> degreesFreedom_
mutableprivate

Definition at line 149 of file convolvedstudentt.hpp.

◆ factors_

std::vector<Real> factors_
mutableprivate

Definition at line 150 of file convolvedstudentt.hpp.

◆ polynCharFnc_

std::vector<std::vector<Real> > polynCharFnc_
mutableprivate

Definition at line 152 of file convolvedstudentt.hpp.

◆ polyConvolved_

std::vector<Real> polyConvolved_
mutableprivate

Definition at line 153 of file convolvedstudentt.hpp.

◆ a_

Real a_ = 0.
mutableprivate

Definition at line 156 of file convolvedstudentt.hpp.

◆ a2_

Real a2_
private

Definition at line 156 of file convolvedstudentt.hpp.