NumericCCDF

Class to compute complementary cumulative density function as integral of it's probability density function. Unstable algorithm.

Constructors

this
this(PDF!T pdf, T[] subdivisions, T b, T epsRel, T epsAbs)

Constructor

Members

Functions

opCall
T opCall(T x)

Examples

Numeric complementary cumulative density function of standard normal distribution

import std.traits, std.mathspecial;
import atmosphere.pdf;

class NormalPDF : PDF!real
{
	real opCall(real x)
	{
		// 1/sqrt(2 PI)
		enum c = 0.398942280401432677939946L;
		return c * exp(-0.5f * x * x);
	}
}

class NormalCCDF : NumericCCDF!real
{
	this()
	{
		super(new NormalPDF, [-3, -1, 0, 1, 3]);
	}
}

auto ccdf = new NormalCCDF;

assert(approxEqual(ccdf(1.3), 1-normalDistribution(1.3)));

Meta