[MATH-1276] Improved performance of sampling and inverse cumulative
probability calculation for geometric distributions.
This commit is contained in:
parent
7fe8a8aff6
commit
df1db29ab4
|
@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||
</properties>
|
||||
<body>
|
||||
<release version="3.6" date="XXXX-XX-XX" description="">
|
||||
<action dev="oertl" type="update" issue="MATH-1276">
|
||||
Improved performance of sampling and inverse cumulative probability calculation
|
||||
for geometric distributions.
|
||||
</action>
|
||||
<action dev="oertl" type="fix" issue="MATH-1277" due-to="Marc Rosen">
|
||||
Fixed incorrect Kendall's tau coefficient calculation due to internal integer overflow.
|
||||
</action>
|
||||
|
|
|
@ -165,4 +165,21 @@ public class GeometricDistribution extends AbstractIntegerDistribution {
|
|||
public boolean isSupportConnected() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int inverseCumulativeProbability(double p) throws OutOfRangeException {
|
||||
if (p < 0 || p > 1) {
|
||||
throw new OutOfRangeException(p, 0, 1);
|
||||
}
|
||||
if (p == 1) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
if (p == 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, (int) Math.ceil((FastMath.log1p(-p)/log1mProbabilityOfSuccess-1)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue