|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.commons.math.distribution.ContinuousDistributionAbstractTest
public abstract class ContinuousDistributionAbstractTest
Abstract base class for ContinuousDistribution
tests.
To create a concrete test class for a continuous distribution implementation, first implement makeDistribution() to return a distribution instance to use in tests. Then implement each of the test data generation methods below. In each case, the test points and test values arrays returned represent parallel arrays of inputs and expected values for the distribution returned by makeDistribution(). Default implementations are provided for the makeInverseXxx methods that just invert the mapping defined by the arrays returned by the makeCumulativeXxx methods.
makeCumulativeTestPoints() -- arguments used to test cumulative probabilities makeCumulativeTestValues() -- expected cumulative probabilites makeInverseCumulativeTestPoints() -- arguments used to test inverse cdf makeInverseCumulativeTestValues() -- expected inverse cdf values
To implement additional test cases with different distribution instances and test data, use the setXxx methods for the instance data in test cases and call the verifyXxx methods to verify results.
Error tolerance can be overriden by implementing getTolerance().
Test data should be validated against reference tables or other packages where possible, and the source of the reference data and/or validation should be documented in the test cases. A framework for validating distribution data against R is included in the /src/test/R source tree.
See NormalDistributionTest
and ChiSquareDistributionTest
for examples.
Constructor Summary | |
---|---|
ContinuousDistributionAbstractTest(String name)
Constructor for ContinuousDistributionAbstractTest. |
Method Summary | |
---|---|
protected double[] |
getCumulativeTestPoints()
|
protected double[] |
getCumulativeTestValues()
|
protected org.apache.commons.math.distribution.ContinuousDistribution |
getDistribution()
|
protected double[] |
getInverseCumulativeTestPoints()
|
protected double[] |
getInverseCumulativeTestValues()
|
protected double |
getTolerance()
|
abstract double[] |
makeCumulativeTestPoints()
Creates the default cumulative probability density test input values |
abstract double[] |
makeCumulativeTestValues()
Creates the default cumulative probability density test expected values |
abstract org.apache.commons.math.distribution.ContinuousDistribution |
makeDistribution()
Creates the default continuous distribution instance to use in tests. |
double[] |
makeInverseCumulativeTestPoints()
Creates the default inverse cumulative probability test input values |
double[] |
makeInverseCumulativeTestValues()
Creates the default inverse cumulative probability density test expected values |
protected void |
setCumulativeTestPoints(double[] cumulativeTestPoints)
|
protected void |
setCumulativeTestValues(double[] cumulativeTestValues)
|
protected void |
setDistribution(org.apache.commons.math.distribution.ContinuousDistribution distribution)
|
protected void |
setInverseCumulativeTestPoints(double[] inverseCumulativeTestPoints)
|
protected void |
setInverseCumulativeTestValues(double[] inverseCumulativeTestValues)
|
protected void |
setTolerance(double tolerance)
|
protected void |
setUp()
Setup sets all test instance data to default values |
protected void |
tearDown()
Cleans up test instance data |
void |
testConsistency()
Verifies that probability computations are consistent |
void |
testCumulativeProbabilities()
Verifies that cumulative probability density calculations match expected values using default test instance data |
void |
testIllegalArguments()
Verifies that illegal arguments are correctly handled |
void |
testInverseCumulativeProbabilities()
Verifies that inverse cumulative probability density calculations match expected values using default test instance data |
protected void |
verifyCumulativeProbabilities()
Verifies that cumulative probability density calculations match expected values using current test instance data |
protected void |
verifyInverseCumulativeProbabilities()
Verifies that inverse cumulative probability density calculations match expected values using current test instance data |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ContinuousDistributionAbstractTest(String name)
name
- Method Detail |
---|
public abstract org.apache.commons.math.distribution.ContinuousDistribution makeDistribution()
public abstract double[] makeCumulativeTestPoints()
public abstract double[] makeCumulativeTestValues()
public double[] makeInverseCumulativeTestPoints()
public double[] makeInverseCumulativeTestValues()
protected void setUp() throws Exception
setUp
in class junit.framework.TestCase
Exception
protected void tearDown() throws Exception
tearDown
in class junit.framework.TestCase
Exception
protected void verifyCumulativeProbabilities() throws Exception
Exception
protected void verifyInverseCumulativeProbabilities() throws Exception
Exception
public void testCumulativeProbabilities() throws Exception
Exception
public void testInverseCumulativeProbabilities() throws Exception
Exception
public void testConsistency() throws Exception
Exception
public void testIllegalArguments() throws Exception
Exception
protected double[] getCumulativeTestPoints()
protected void setCumulativeTestPoints(double[] cumulativeTestPoints)
cumulativeTestPoints
- The cumulativeTestPoints to set.protected double[] getCumulativeTestValues()
protected void setCumulativeTestValues(double[] cumulativeTestValues)
cumulativeTestValues
- The cumulativeTestValues to set.protected org.apache.commons.math.distribution.ContinuousDistribution getDistribution()
protected void setDistribution(org.apache.commons.math.distribution.ContinuousDistribution distribution)
distribution
- The distribution to set.protected double[] getInverseCumulativeTestPoints()
protected void setInverseCumulativeTestPoints(double[] inverseCumulativeTestPoints)
inverseCumulativeTestPoints
- The inverseCumulativeTestPoints to set.protected double[] getInverseCumulativeTestValues()
protected void setInverseCumulativeTestValues(double[] inverseCumulativeTestValues)
inverseCumulativeTestValues
- The inverseCumulativeTestValues to set.protected double getTolerance()
protected void setTolerance(double tolerance)
tolerance
- The tolerance to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |