22#include <ql/errors.hpp>
23#include <ql/math/functional.hpp>
24#include <ql/math/solvers1d/brent.hpp>
25#include <ql/math/distributions/normaldistribution.hpp>
26#include <ql/methods/finitedifferences/utilities/cevrndcalculator.hpp>
27#include <boost/math/special_functions/gamma.hpp>
28#include <boost/math/distributions/non_central_chi_squared.hpp>
36 delta_((1.0-2.0*beta)/(1.0-beta)),
38 QL_REQUIRE(beta != 1.0,
"beta can not be one");
43 return 1.0-boost::math::gamma_p(-0.5*
delta_+1.0,
x0_/(2.0*t));
54 1.0/(2.0*(1.0-
beta_)));
61 return boost::math::pdf(
62 boost::math::non_central_chi_squared_distribution<Real>(
66 return boost::math::pdf(
67 boost::math::non_central_chi_squared_distribution<Real>(
76 return 1.0 - boost::math::cdf(
77 boost::math::non_central_chi_squared_distribution<Real>(
80 return 1.0 - boost::math::cdf(
81 boost::math::non_central_chi_squared_distribution<Real>(
89 c = std::max(c, -0.45*b);
91 const Real h = 1 - 2*(b+c)*(b+3*c)/(3*
squared(b+2*c));
93 const Real m = (h-1)*(1-3*h);
95 const Real u = (std::pow(a/(b+c), h) - (1 + h*p*(h-1-0.5*(2-h)*m*p)))/
96 (h*std::sqrt(2*p)*(1+0.5*m*p));
116 invX(brent.
solve(cdfApprox, 1e-8, y0, 0.02*y0) * t);
125 const Real x = t * boost::math::quantile(
126 boost::math::non_central_chi_squared_distribution<Real>(
CEVRNDCalculator(Real f0, Real alpha, Real beta)
Real pdf(Real f, Time t) const override
Real massAtZero(Time t) const
Real invcdf(Real q, Time t) const override
Real cdf(Real f, Time t) const override
Real sankaranApprox(Real f, Time t, Real x) const
Inverse cumulative normal distribution function.
Real inverseCDF(Real p, Time t) const
void setMaxEvaluations(Size evaluations)
Real solve(const F &f, Real accuracy, Real guess, Real step) const
Real Time
continuous quantity with 1-year units