NumericCDF

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

Constructors

this
this(PDF!T pdf, T[] subdivisions, T a = -T.infinity, T epsRel = 1e-6, T epsAbs = 0)

Constructor

Members

Functions

opCall
T opCall(T x)

Examples

Numeric cumulative density function of standard normal distribution

1 import std.traits, std.mathspecial;
2 import atmosphere.pdf;
3 
4 class NormalPDF : PDF!real
5 {
6 	real opCall(real x)
7 	{
8 		// 1/sqrt(2 PI)
9 		enum c = 0.398942280401432677939946L;
10 		return c * exp(-0.5f * x * x);
11 	}
12 }
13 
14 class NormalCDF : NumericCDF!real
15 {
16 	this()
17 	{
18 		super(new NormalPDF, [-3, -1, 0, 1, 3]);
19 	}
20 }
21 
22 auto cdf = new NormalCDF;
23 
24 assert(approxEqual(cdf(1.3), normalDistribution(1.3)));

Meta