37 const Real errmax = 1e-12;
38 const Size itrmax = 10000;
41 Real u = std::exp(-lam);
50 t = std::exp((1 -
t) *
51 (2 -
t/(f2+1)))/std::sqrt(2.0*
M_PI*(f2 + 1.0));
54 t = std::exp(f2*std::log(x2) - x2 -
79 if (!flag &&
n <= itrmax)
82 bound =
t * x / f_x_2n;
83 if (bound <= errmax || n > itrmax)
88 if (bound > errmax)
QL_FAIL(
"didn't converge");
97 const Real m = (h-1)*(1-3*h);
99 const Real u= (std::pow(x/(
df_+
ncp_), h) - (1 + h*p*(h-1-0.5*(2-h)*m*p)))/
100 (h*std::sqrt(2*p)*(1+0.5*m*p));
109 : nonCentralDist_(df, ncp),
111 maxEvaluations_(maxEvaluations),
112 accuracy_(accuracy) {
Chi-square (central and non-central) distributions.
Real operator()(Real x) const
Cumulative normal distribution function.
const Size maxEvaluations_
InverseNonCentralCumulativeChiSquareDistribution(Real df, Real ncp, Size maxEvaluations=10, Real accuracy=1e-8)
Real operator()(Real x) const
NonCentralCumulativeChiSquareDistribution nonCentralDist_
Real operator()(Real x) const
Real operator()(Real x) const
void setMaxEvaluations(Size evaluations)
Real solve(const F &f, Real accuracy, Real guess, Real step) const
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container
functionals and combinators not included in the STL
normal, cumulative and inverse cumulative distributions
ext::shared_ptr< BlackVolTermStructure > v