Fixed implementation of EmpiricalDistributionImpl#getUpperBounds to match interface
contract. Added getGeneratorUpperBounds method to EmpiricalDistributionImpl providing previous behavior. Jira: Math-298 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@817128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fbeb731b9
commit
e9771d7eb5
|
@ -124,7 +124,7 @@ public interface EmpiricalDistribution {
|
|||
/**
|
||||
* Returns the array of upper bounds for the bins. Bins are: <br/>
|
||||
* [min,upperBounds[0]],(upperBounds[0],upperBounds[1]],...,
|
||||
* (upperBounds[binCount-1],max].
|
||||
* (upperBounds[binCount-2], upperBounds[binCount-1] = max].
|
||||
*
|
||||
* @return array of bin upper bounds
|
||||
*/
|
||||
|
|
|
@ -39,6 +39,11 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
</properties>
|
||||
<body>
|
||||
<release version="2.1" date="TBD" description="TBD">
|
||||
<action dev="psteitz" tyoe="fix" issue="MATH-298">
|
||||
Fixed implementation of EmpiricalDistributionImpl#getUpperBounds to match
|
||||
interface contract. Added getGeneratorUpperBounds method to
|
||||
EmpiricalDistributionImpl providing previous behavior.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-293" due-to="Benjamin McCann">
|
||||
Fixed a OutOfBoundException in simplex solver when some constraints are tight.
|
||||
</action>
|
||||
|
|
|
@ -118,7 +118,7 @@ public final class EmpiricalDistributionTest extends RetryTestCase {
|
|||
(empiricalDistribution2.getSampleStats().getStandardDeviation(),
|
||||
1.0173699343977738,10E-7);
|
||||
|
||||
double[] bounds = empiricalDistribution2.getUpperBounds();
|
||||
double[] bounds = ((EmpiricalDistributionImpl) empiricalDistribution2).getGeneratorUpperBounds();
|
||||
assertEquals(bounds.length, 100);
|
||||
assertEquals(bounds[99], 1.0, 10e-12);
|
||||
|
||||
|
@ -227,6 +227,20 @@ public final class EmpiricalDistributionTest extends RetryTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MATH-298
|
||||
*/
|
||||
public void testGetBinUpperBounds() {
|
||||
double[] testData = {0, 1, 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10};
|
||||
EmpiricalDistributionImpl dist = new EmpiricalDistributionImpl(5);
|
||||
dist.load(testData);
|
||||
double[] expectedBinUpperBounds = {2, 4, 6, 8, 10};
|
||||
double[] expectedGeneratorUpperBounds = {4d/13d, 7d/13d, 9d/13d, 11d/13d, 1};
|
||||
double tol = 10E-12;
|
||||
TestUtils.assertEquals(expectedBinUpperBounds, dist.getUpperBounds(), tol);
|
||||
TestUtils.assertEquals(expectedGeneratorUpperBounds, dist.getGeneratorUpperBounds(), tol);
|
||||
}
|
||||
|
||||
private void verifySame(EmpiricalDistribution d1, EmpiricalDistribution d2) {
|
||||
assertEquals(d1.isLoaded(), d2.isLoaded());
|
||||
assertEquals(d1.getBinCount(), d2.getBinCount());
|
||||
|
|
Loading…
Reference in New Issue