org.apache.commons.math.distribution
Class IntegerDistributionAbstractTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.math.distribution.IntegerDistributionAbstractTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
BinomialDistributionTest, HypergeometricDistributionTest, PascalDistributionTest, PoissonDistributionTest, ZipfDistributionTest

public abstract class IntegerDistributionAbstractTest
extends junit.framework.TestCase

Abstract base class for IntegerDistribution tests.

To create a concrete test class for an integer distribution implementation, implement makeDistribution() to return a distribution instance to use in tests and 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().

makeDensityTestPoints() -- arguments used to test probability density calculation makeDensityTestValues() -- expected probability densities makeCumulativeTestPoints() -- arguments used to test cumulative probabilities makeCumulativeTestValues() -- expected cumulative probabilites makeInverseCumulativeTestPoints() -- arguments used to test inverse cdf evaluation 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.

Version:
$Revision: 762118 $ $Date: 2009-04-05 12:55:59 -0400 (Sun, 05 Apr 2009) $

Constructor Summary
IntegerDistributionAbstractTest(String name)
          Constructor for IntegerDistributionAbstractTest.
 
Method Summary
protected  int[] getCumulativeTestPoints()
           
protected  double[] getCumulativeTestValues()
           
protected  int[] getDensityTestPoints()
           
protected  double[] getDensityTestValues()
           
protected  org.apache.commons.math.distribution.IntegerDistribution getDistribution()
           
protected  double[] getInverseCumulativeTestPoints()
           
protected  int[] getInverseCumulativeTestValues()
           
protected  double getTolerance()
           
abstract  int[] makeCumulativeTestPoints()
          Creates the default cumulative probability density test input values
abstract  double[] makeCumulativeTestValues()
          Creates the default cumulative probability density test expected values
abstract  int[] makeDensityTestPoints()
          Creates the default probability density test input values
abstract  double[] makeDensityTestValues()
          Creates the default probability density test expected values
abstract  org.apache.commons.math.distribution.IntegerDistribution makeDistribution()
          Creates the default discrete distribution instance to use in tests.
abstract  double[] makeInverseCumulativeTestPoints()
          Creates the default inverse cumulative probability test input values
abstract  int[] makeInverseCumulativeTestValues()
          Creates the default inverse cumulative probability density test expected values
protected  void setCumulativeTestPoints(int[] cumulativeTestPoints)
           
protected  void setCumulativeTestValues(double[] cumulativeTestValues)
           
protected  void setDensityTestPoints(int[] densityTestPoints)
           
protected  void setDensityTestValues(double[] densityTestValues)
           
protected  void setDistribution(org.apache.commons.math.distribution.IntegerDistribution distribution)
           
protected  void setInverseCumulativeTestPoints(double[] inverseCumulativeTestPoints)
           
protected  void setInverseCumulativeTestValues(int[] 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 testCumulativeProbabilities()
          Verifies that cumulative probability density calculations match expected values using default test instance data
 void testDensities()
          Verifies that probability density calculations match expected values using default test instance data
 void testFloatingPointArguments()
          Verifies that floating point arguments are correctly handled by cumulativeProbablility(-,-) JIRA: MATH-184
 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 verifyDensities()
          Verifies that 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

IntegerDistributionAbstractTest

public IntegerDistributionAbstractTest(String name)
Constructor for IntegerDistributionAbstractTest.

Parameters:
name -
Method Detail

makeDistribution

public abstract org.apache.commons.math.distribution.IntegerDistribution makeDistribution()
Creates the default discrete distribution instance to use in tests.


makeDensityTestPoints

public abstract int[] makeDensityTestPoints()
Creates the default probability density test input values


makeDensityTestValues

public abstract double[] makeDensityTestValues()
Creates the default probability density test expected values


makeCumulativeTestPoints

public abstract int[] makeCumulativeTestPoints()
Creates the default cumulative probability density test input values


makeCumulativeTestValues

public abstract double[] makeCumulativeTestValues()
Creates the default cumulative probability density test expected values


makeInverseCumulativeTestPoints

public abstract double[] makeInverseCumulativeTestPoints()
Creates the default inverse cumulative probability test input values


makeInverseCumulativeTestValues

public abstract int[] makeInverseCumulativeTestValues()
Creates the default inverse cumulative probability density test expected values


setUp

protected void setUp()
              throws Exception
Setup sets all test instance data to default values

Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Cleans up test instance data

Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

verifyDensities

protected void verifyDensities()
                        throws Exception
Verifies that probability density calculations match expected values using current test instance data

Throws:
Exception

verifyCumulativeProbabilities

protected void verifyCumulativeProbabilities()
                                      throws Exception
Verifies that cumulative probability density calculations match expected values using current test instance data

Throws:
Exception

verifyInverseCumulativeProbabilities

protected void verifyInverseCumulativeProbabilities()
                                             throws Exception
Verifies that inverse cumulative probability density calculations match expected values using current test instance data

Throws:
Exception

testDensities

public void testDensities()
                   throws Exception
Verifies that probability density calculations match expected values using default test instance data

Throws:
Exception

testCumulativeProbabilities

public void testCumulativeProbabilities()
                                 throws Exception
Verifies that cumulative probability density calculations match expected values using default test instance data

Throws:
Exception

testFloatingPointArguments

public void testFloatingPointArguments()
                                throws Exception
Verifies that floating point arguments are correctly handled by cumulativeProbablility(-,-) JIRA: MATH-184

Throws:
Exception

testInverseCumulativeProbabilities

public void testInverseCumulativeProbabilities()
                                        throws Exception
Verifies that inverse cumulative probability density calculations match expected values using default test instance data

Throws:
Exception

testIllegalArguments

public void testIllegalArguments()
                          throws Exception
Verifies that illegal arguments are correctly handled

Throws:
Exception

getCumulativeTestPoints

protected int[] getCumulativeTestPoints()
Returns:
Returns the cumulativeTestPoints.

setCumulativeTestPoints

protected void setCumulativeTestPoints(int[] cumulativeTestPoints)
Parameters:
cumulativeTestPoints - The cumulativeTestPoints to set.

getCumulativeTestValues

protected double[] getCumulativeTestValues()
Returns:
Returns the cumulativeTestValues.

setCumulativeTestValues

protected void setCumulativeTestValues(double[] cumulativeTestValues)
Parameters:
cumulativeTestValues - The cumulativeTestValues to set.

getDensityTestPoints

protected int[] getDensityTestPoints()
Returns:
Returns the densityTestPoints.

setDensityTestPoints

protected void setDensityTestPoints(int[] densityTestPoints)
Parameters:
densityTestPoints - The densityTestPoints to set.

getDensityTestValues

protected double[] getDensityTestValues()
Returns:
Returns the densityTestValues.

setDensityTestValues

protected void setDensityTestValues(double[] densityTestValues)
Parameters:
densityTestValues - The densityTestValues to set.

getDistribution

protected org.apache.commons.math.distribution.IntegerDistribution getDistribution()
Returns:
Returns the distribution.

setDistribution

protected void setDistribution(org.apache.commons.math.distribution.IntegerDistribution distribution)
Parameters:
distribution - The distribution to set.

getInverseCumulativeTestPoints

protected double[] getInverseCumulativeTestPoints()
Returns:
Returns the inverseCumulativeTestPoints.

setInverseCumulativeTestPoints

protected void setInverseCumulativeTestPoints(double[] inverseCumulativeTestPoints)
Parameters:
inverseCumulativeTestPoints - The inverseCumulativeTestPoints to set.

getInverseCumulativeTestValues

protected int[] getInverseCumulativeTestValues()
Returns:
Returns the inverseCumulativeTestValues.

setInverseCumulativeTestValues

protected void setInverseCumulativeTestValues(int[] inverseCumulativeTestValues)
Parameters:
inverseCumulativeTestValues - The inverseCumulativeTestValues to set.

getTolerance

protected double getTolerance()
Returns:
Returns the tolerance.

setTolerance

protected void setTolerance(double tolerance)
Parameters:
tolerance - The tolerance to set.


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.