QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
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
31namespace QuantLib {
32
34 public:
36 QL_REQUIRE(a>0.0, "invalid parameter for gamma distribution");
37 }
38 Real operator()(Real x) const;
39 private:
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 */
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
Gamma function class.
Real logValue(Real x) const
Real value(Real x) const
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
Custom types.