Constructor
Call operator
Numeric quantile function of standard normal distribution
import std.traits, std.mathspecial; import atmosphere.pdf; import atmosphere.cdf; class NormalPDF : PDF!real { real opCall(real x) { // 1/sqrt(2 PI) enum c = 0.398942280401432677939946L; return c * exp(-0.5f * x * x); } } class NormalCDF : NumericCDF!real ///$(RED Unstable) algorithm. { this() { super(new NormalPDF, [-3, -1, 0, 1, 3]); } } class NormalQuantile : NumericQuantile!real ///$(RED Unstable) algorithm. { this() { super(new NormalCDF); } } auto qf = new NormalQuantile; assert(approxEqual(qf(0.3), normalDistributionInverse(0.3)));
Numeric quantile function of Generalized Hyperbolic distribution
import atmosphere.pdf; import atmosphere.cdf; import atmosphere.params; import atmosphere.moment; class GHypCDF: NumericCDF!real ///$(RED Unstable) algorithm. { this(real lambda, GHypChiPsi!real params) { immutable mu = 0; auto pdf = new GeneralizedHyperbolicPDF!real(lambda, params.alpha, params.beta, params.delta, mu); immutable mean = generalizedHyperbolicMean!real(lambda, params.beta, params.chi, params.psi); super(pdf, [mean]); } } class GHypQuantile : NumericQuantile!real ///$(RED Unstable) algorithm. { this(real lambda, GHypChiPsi!real params) { super(new GHypCDF(lambda, params), -1000, 1000); } } auto qf = new GHypQuantile(0.5, GHypChiPsi!real(5, 0.7, 0.6)); assert(approxEqual(qf(0.95), 40.9263)); assert(approxEqual(qf(0.99), 64.977));
Class to compute quantile function as root of it's cumulative density function. Unstable algorithm.