commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/distribution GammaDistributionTest.java
Date Mon, 31 May 2004 00:55:22 GMT
psteitz     2004/05/30 17:55:22

  Modified:    math/src/test/org/apache/commons/math/distribution
                        GammaDistributionTest.java
  Log:
  Modified to extent ContinuousDistributionAbstractTest.
  
  Revision  Changes    Path
  1.17      +65 -4     jakarta-commons/math/src/test/org/apache/commons/math/distribution/GammaDistributionTest.java
  
  Index: GammaDistributionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/distribution/GammaDistributionTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- GammaDistributionTest.java	23 May 2004 21:34:19 -0000	1.16
  +++ GammaDistributionTest.java	31 May 2004 00:55:22 -0000	1.17
  @@ -16,12 +16,73 @@
   
   package org.apache.commons.math.distribution;
   
  -import junit.framework.TestCase;
  -
   /**
  + * Test cases for GammaDistribution.
  + * Extends ContinuousDistributionAbstractTest.  See class javadoc for
  + * ContinuousDistributionAbstractTest for details.
  + * 
    * @version $Revision$ $Date$
    */
  -public class GammaDistributionTest extends TestCase {
  +public class GammaDistributionTest extends ContinuousDistributionAbstractTest {
  +    
  +    /**
  +     * Constructor for GammaDistributionTest.
  +     * @param name
  +     */
  +    public GammaDistributionTest(String name) {
  +        super(name);
  +    }
  +    
  +    //-------------- Implementations for abstract methods -----------------------
  +    
  +    /** Creates the default continuous distribution instance to use in tests. */
  +    public ContinuousDistribution makeDistribution() {
  +        return DistributionFactory.newInstance().createGammaDistribution(4d, 2d);
  +    }   
  +    
  +    /** Creates the default cumulative probability distribution test input values */
  +    public double[] makeCumulativeTestPoints() {
  +        // quantiles computed using R version 1.8.1 (linux version)
  +        return new double[] {0.8571048, 1.646497, 2.179731, 2.732637,
  +            3.489539, 26.12448, 20.09024, 17.53455,
  +            15.50731, 13.36157};
  +    }
  +    
  +    /** Creates the default cumulative probability density test expected values */
  +    public double[] makeCumulativeTestValues() {
  +        return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
  +                0.990d, 0.975d, 0.950d, 0.900d}; 
  +    }
  +    
  +    // --------------------- Override tolerance  --------------
  +    protected void setup() throws Exception {
  +        super.setUp();
  +        setTolerance(1E-6);
  +    }
  +
  +    //---------------------------- Additional test cases -------------------------
  +    public void testParameterAccessors() {
  +        GammaDistribution distribution = (GammaDistribution) getDistribution();
  +        assertEquals(4d, distribution.getAlpha(), 0);
  +        distribution.setAlpha(3d);
  +        assertEquals(3d, distribution.getAlpha(), 0);
  +        assertEquals(2d, distribution.getBeta(), 0);
  +        distribution.setBeta(4d);
  +        assertEquals(4d, distribution.getBeta(), 0);
  +        try {
  +            distribution.setAlpha(0d);
  +            fail("Expecting IllegalArgumentException for alpha = 0");
  +        } catch (IllegalArgumentException ex) {
  +            // expected
  +        }
  +        try {
  +            distribution.setBeta(0d);
  +            fail("Expecting IllegalArgumentException for beta = 0");
  +        } catch (IllegalArgumentException ex) {
  +            // expected
  +        }
  +    } 
  +    
       public void testProbabilities() throws Exception {
           testProbability(-1.000, 4.0, 2.0, .0000);
           testProbability(15.501, 4.0, 2.0, .9499);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message