public abstract class NumericQuantile(T) : Quantile!T

Class to compute quantile function as root of it's cumulative density function. Unstable algorithm.

Example

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)));

Example

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));
import std.stdio, std.conv;
assert(approxEqual(qf(0.95), 40.9263));
assert(approxEqual(qf(0.99), 64.977));

public this(
    CDF!T cdf, 
    T a = -T.max, 
    T b = T.max)

Constructor

Parameters

cdf

The CDF to to inverse.

a

(optional) The lower bound.

b

(optional) The upper bound.

public final T opCall(T x)

Call operator

Contracts

in
{
    assert (x >= 0);
    assert (x <= 1);
}
out (result)
{
    assert (!result.isNaN);
}

Functions

this

Constructor

finalopCall

Call operator