QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
convolvedstudentt.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2014 Jose Aparicio
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#ifndef convolved_student_t_hpp
21#define convolved_student_t_hpp
22
23#include <ql/types.hpp>
24#include <vector>
25#include <numeric>
26#include <functional>
27
28namespace QuantLib {
29
60 class CumulativeBehrensFisher { // ODD orders only by now, rename?
61 public:
65 QL_DEPRECATED
67
71 QL_DEPRECATED
79 const std::vector<Integer>& degreesFreedom = std::vector<Integer>(),
80 const std::vector<Real>& factors = std::vector<Real>());
81
83 const std::vector<Integer>& degreeFreedom() const {
84 return degreesFreedom_;
85 }
87 const std::vector<Real>& factors() const {
88 return factors_;
89 }
90 private:
109 // move outside of the class, as a separate problem?
110 std::vector<Real> polynCharactT(Natural n) const;
111
112 std::vector<Real> convolveVectorPolynomials(
113 const std::vector<Real>& v1,
114 const std::vector<Real>& v2) const ;
115 public:
137 Probability operator()(Real x) const;
138
146 Probability density(Real x) const;
147
148 private:
149 mutable std::vector<Integer> degreesFreedom_;
150 mutable std::vector<Real> factors_;
151
152 mutable std::vector<std::vector<Real> > polynCharFnc_;
153 mutable std::vector<Real> polyConvolved_;
154
155 // cached factor in the exponential of the characteristic function
156 mutable Real a_ = 0., a2_;
157 };
158
159
160
173 public:
177 QL_DEPRECATED
179
183 QL_DEPRECATED
192 const std::vector<Integer>& degreesFreedom = std::vector<Integer>(),
193 const std::vector<Real>& factors = std::vector<Real>(),
194 Real accuracy = 1.e-6);
196 Real operator()(Probability q) const;
197
198 private:
201 };
202
203}
204
205#endif
Cumulative (generalized) BehrensFisher distribution.
std::vector< std::vector< Real > > polynCharFnc_
const std::vector< Real > & factors() const
Factors in the linear combination.
Probability density(Real x) const
Returns the probability density of the resulting distribution.
QL_DEPRECATED typedef Probability result_type
Probability operator()(Real x) const
Returns the cumulative probability of the resulting distribution.
QL_DEPRECATED typedef Real argument_type
std::vector< Real > convolveVectorPolynomials(const std::vector< Real > &v1, const std::vector< Real > &v2) const
std::vector< Integer > degreesFreedom_
std::vector< Real > polynCharactT(Natural n) const
Student t characteristic polynomials.
const std::vector< Integer > & degreeFreedom() const
Degrees of freedom of the Ts involved in the convolution.
Inverse of the cumulative of the convolution of odd-T distributions.
Real operator()(Probability q) const
Returns the cumulative inverse value.
QL_DEPRECATED typedef Probability argument_type
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Probability
probability
Definition: types.hpp:82
Definition: any.hpp:35