Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.


This module contains algorithms for the Cornish-Fisher Expansion.
John Michael Hall
T cornishFisherInvCDF(T)(const T p, const T mu, const T std, const T skewness, const T excessKurtosis)
if (isFloatingPoint!T);
Approximates the inverse CDF of a continuous distribution using the Cornish-Fisher expansion.
It is generally recommended to only use the Cornish-Fisher expansion with distributions that are similar to the normal distribution. Extreme values of skewness or excessKurtosis can result in poorer approximations.
T p quantile to calculate inverse CDF
T mu mean
T std standard deviation
T skewness skewness
T excessKurtosis excess kurtosis (kurtosis - 3)
import mir.test: shouldApprox;

0.99.cornishFisherInvCDF(0, 1, 0.1, 1).shouldApprox == 2.629904;
0.99.cornishFisherInvCDF(0.1, 0.2, 0.1, 1).shouldApprox == 0.6259808;
T cornishFisherInvCDF(T)(const T p, const T skewness = 0, const T excessKurtosis = 0)
if (isFloatingPoint!T);
Ditto, but assumes mu = 0 and std = 1
T p quantile to calculate inverse CDF
T skewness skewness (default = 0)
T excessKurtosis excess kurtosis (kurtosis - 3) (default = 0)
import mir.test: shouldApprox;

0.5.cornishFisherInvCDF.shouldApprox == 0;
0.5.cornishFisherInvCDF(1).shouldApprox == -0.1666667;
0.5.cornishFisherInvCDF(-1, 0).shouldApprox == 0.1666667;

0.9.cornishFisherInvCDF(0.1, 0).shouldApprox == 1.292868;
0.9.cornishFisherInvCDF(0.1, 1).shouldApprox ==  1.220374;
0.9.cornishFisherInvCDF(0.1, -1).shouldApprox == 1.365363;

0.99.cornishFisherInvCDF(0.1, 0).shouldApprox == 2.396116;
0.99.cornishFisherInvCDF(0.1, 1).shouldApprox == 2.629904;
0.99.cornishFisherInvCDF(0.1, -1).shouldApprox == 2.162328;

0.01.cornishFisherInvCDF(0.1, 0).shouldApprox == -2.249053  ;
0.01.cornishFisherInvCDF(0.1, 1).shouldApprox == -2.482841;
0.01.cornishFisherInvCDF(0.1, -1).shouldApprox == -2.015265;