[MATH-1276] Improved performance of sampling and inverse cumulative
probability calculation for geometric distributions.
This commit is contained in:
parent
4158323ee4
commit
2fd6c8fa1e
|
@ -54,6 +54,10 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||
</release>
|
||||
|
||||
<release version="4.0" date="XXXX-XX-XX" description="">
|
||||
<action dev="oertl" type="update" issue="MATH-1276"> <!-- backported to 3.6 -->
|
||||
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"> <!-- backported to 3.6 -->
|
||||
Fixed incorrect Kendall's tau coefficient calculation due to internal integer overflow.
|
||||
</action>
|
||||
|
|
|
@ -172,4 +172,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