quantile method
Gives the quantile associated with an input probability.
Approximation within 4.5E-4 (Abramowitz 26.2.23) of the normal
quantile associated with p
.
Implementation
num quantile(num p) {
final standardDeviation = math.sqrt(variance),
restrictedP = p > 0.5 ? 1 - p : p,
t = math.sqrt(math.log(1 / restrictedP / restrictedP)),
tps = [for (var i = 0; i < _nd; i++) math.pow(t, i)],
cs = [for (var i = 0; i < _nc; i++) _c[i] * tps[i]]
.fold(0.0, (a, b) => a + b),
ds = [for (var i = 0; i < _nd; i++) _d[i] * tps[i]]
.fold(0.0, (a, b) => a + b),
z = t - cs / ds;
return (p < 0.5 ? -1 : 1) * (mean + z * standardDeviation);
}