inverseCumulativeProbability method
The Inverse Cumulative Distribution Function (PPT), or quantile function.
Returns the value of x
for which the cumulative probability density is
p
. Throws InvalidProbability, if p
is out of range.
Implementation
@override
int inverseCumulativeProbability(num p) {
InvalidProbability.check(p);
if (p == 0) {
return lowerBound;
} else if (p == 1) {
return upperBound;
} else {
var sum = 0.0;
for (var k = lowerBound; k < upperBound; k++) {
sum += probability(k);
if (p <= sum) {
return k;
}
}
return upperBound;
}
}