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
31namespace QuantLib {
32
33 class CumulativeGammaDistribution {
34 public:
35 /*! \deprecated Use `auto` or `decltype` instead.
36 Deprecated in version 1.29.
37 */
38 QL_DEPRECATED
39 typedef Real argument_type;
40
41 /*! \deprecated Use `auto` or `decltype` instead.
42 Deprecated in version 1.29.
43 */
44 QL_DEPRECATED
45 typedef Real result_type;
46
47 CumulativeGammaDistribution(Real a) : a_(a) {
48 QL_REQUIRE(a>0.0, "invalid parameter for gamma distribution");
49 }
50 Real operator()(Real x) const;
51 private:
52 Real a_;
53 };
54
55 //! Gamma function class
56 /*! This is a function defined by
57 \f[
58 \Gamma(z) = \int_0^{\infty}t^{z-1}e^{-t}dt
59 \f]
60
61 The implementation of the algorithm was inspired by
62 "Numerical Recipes in C", 2nd edition,
63 Press, Teukolsky, Vetterling, Flannery, chapter 6
64
65 \test the correctness of the returned value is tested by
66 checking it against known good results.
67 */
68 class GammaFunction {
69 public:
70 /*! \deprecated Use `auto` or `decltype` instead.
71 Deprecated in version 1.29.
72 */
73 QL_DEPRECATED
74 typedef Real argument_type;
75
76 /*! \deprecated Use `auto` or `decltype` instead.
77 Deprecated in version 1.29.
78 */
79 QL_DEPRECATED
80 typedef Real result_type;
81
82 Real value(Real x) const;
83 Real logValue(Real x) const;
84 private:
85 static const Real c1_, c2_, c3_, c4_, c5_, c6_;
86 };
87
88}
89
90
91#endif
92

source code of quantlib/ql/math/distributions/gammadistribution.hpp