QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
distributions
gammadistribution.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) 2002, 2003 Sadruddin Rejeb
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 gammadistribution.hpp
21
\brief Gamma distribution
22
*/
23
24
#ifndef quantlib_math_gamma_distribution_h
25
#define quantlib_math_gamma_distribution_h
26
27
#include <
ql/errors.hpp
>
28
#include <
ql/types.hpp
>
29
#include <functional>
30
31
namespace
QuantLib
{
32
33
class
CumulativeGammaDistribution
{
34
public
:
35
CumulativeGammaDistribution
(
Real
a) :
a_
(a) {
36
QL_REQUIRE
(a>0.0,
"invalid parameter for gamma distribution"
);
37
}
38
Real
operator()
(
Real
x)
const
;
39
private
:
40
Real
a_
;
41
};
42
43
//! Gamma function class
44
/*! This is a function defined by
45
\f[
46
\Gamma(z) = \int_0^{\infty}t^{z-1}e^{-t}dt
47
\f]
48
49
The implementation of the algorithm was inspired by
50
"Numerical Recipes in C", 2nd edition,
51
Press, Teukolsky, Vetterling, Flannery, chapter 6
52
53
\test the correctness of the returned value is tested by
54
checking it against known good results.
55
*/
56
class
GammaFunction
{
57
public
:
58
Real
value
(
Real
x)
const
;
59
Real
logValue
(
Real
x)
const
;
60
private
:
61
static
const
Real
c1_
,
c2_
,
c3_
,
c4_
,
c5_
,
c6_
;
62
};
63
64
}
65
66
67
#endif
QuantLib::CumulativeGammaDistribution
Definition:
gammadistribution.hpp:33
QuantLib::CumulativeGammaDistribution::a_
Real a_
Definition:
gammadistribution.hpp:40
QuantLib::CumulativeGammaDistribution::operator()
Real operator()(Real x) const
Definition:
gammadistribution.cpp:24
QuantLib::CumulativeGammaDistribution::CumulativeGammaDistribution
CumulativeGammaDistribution(Real a)
Definition:
gammadistribution.hpp:35
QuantLib::GammaFunction
Gamma function class.
Definition:
gammadistribution.hpp:56
QuantLib::GammaFunction::c1_
static const Real c1_
Definition:
gammadistribution.hpp:61
QuantLib::GammaFunction::c3_
static const Real c3_
Definition:
gammadistribution.hpp:61
QuantLib::GammaFunction::logValue
Real logValue(Real x) const
Definition:
gammadistribution.cpp:69
QuantLib::GammaFunction::c6_
static const Real c6_
Definition:
gammadistribution.hpp:61
QuantLib::GammaFunction::c5_
static const Real c5_
Definition:
gammadistribution.hpp:61
QuantLib::GammaFunction::c2_
static const Real c2_
Definition:
gammadistribution.hpp:61
QuantLib::GammaFunction::value
Real value(Real x) const
Definition:
gammadistribution.cpp:84
QuantLib::GammaFunction::c4_
static const Real c4_
Definition:
gammadistribution.hpp:61
errors.hpp
Classes and functions for error handling.
QL_REQUIRE
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition:
errors.hpp:117
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib
Definition:
any.hpp:35
types.hpp
Custom types.
Generated by
Doxygen
1.9.5