Removed dependency on DistributionFactory.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@545192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brent Worden 2007-06-07 14:35:04 +00:00
parent b345aa99c1
commit a012ec83ec
27 changed files with 39 additions and 457 deletions

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* The Binomial Distribution.
*
* Instances of BinomialDistribution objects should be created using
* {@link DistributionFactory#createBinomialDistribution(int, double)}.
*
* <p>
* References:
* <ul>

View File

@ -19,8 +19,6 @@ package org.apache.commons.math.distribution;
/**
* Cauchy Distribution.
* Instances of CauchyDistribution objects should be created using
* {@link DistributionFactory#createCauchyDistribution(double, double)}.<p>
*
* <p>
* References:<p>

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* The Chi-Squared Distribution.
*
* Instances of ChiSquaredDistribution objects should be created using
* {@link DistributionFactory#createChiSquareDistribution(double)}.
*
* <p>
* References:
* <ul>

View File

@ -17,8 +17,6 @@
package org.apache.commons.math.distribution;
import org.apache.commons.discovery.tools.DiscoverClass;
/**
* This factory provids the means to create common statistical distributions.
* The following distributions are supported:
@ -45,6 +43,8 @@ import org.apache.commons.discovery.tools.DiscoverClass;
* </pre>
*
* @version $Revision$ $Date$
* @deprecated pluggability of distribution instances is now provided through
* constructors and setters.
*/
public abstract class DistributionFactory {
/**
@ -59,16 +59,7 @@ public abstract class DistributionFactory {
* @return a new factory.
*/
public static DistributionFactory newInstance() {
DistributionFactory factory = null;
try {
DiscoverClass dc = new DiscoverClass();
factory = (DistributionFactory) dc.newInstance(
DistributionFactory.class,
"org.apache.commons.math.distribution.DistributionFactoryImpl");
} catch(Throwable t) {
return new DistributionFactoryImpl();
}
return factory;
return new DistributionFactoryImpl();
}
/**

View File

@ -21,6 +21,8 @@ package org.apache.commons.math.distribution;
* Commons-Math.
*
* @version $Revision$ $Date$
* @deprecated pluggability of distribution instances is now provided through
* constructors and setters.
*/
public class DistributionFactoryImpl extends DistributionFactory {

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* The Exponential Distribution.
*
* Instances of ExponentialDistribution objects should be created using
* {@link DistributionFactory#createExponentialDistribution(double)}.
*
* <p>
* References:
* <ul>

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* F-Distribution.
*
* Instances of FDistribution objects should be created using
* {@link DistributionFactory#createFDistribution(double,double)}.
*
* <p>
* References:
* <ul>

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* The Gamma Distribution.
*
* Instances of GammaDistribution objects should be created using
* {@link DistributionFactory#createGammaDistribution(double,double)}.
*
* <p>
* References:
* <ul>

View File

@ -20,9 +20,6 @@ package org.apache.commons.math.distribution;
/**
* The Hypergeometric Distribution.
*
* Instances of HypergeometricDistribution objects should be created using
* {@link DistributionFactory#createHypergeometricDistribution(int, int, int)}.
*
* <p>
* References:
* <ul>

View File

@ -19,8 +19,6 @@ package org.apache.commons.math.distribution;
/**
* Normal (Gauss) Distribution.
* Instances of NormalDistribution objects should be created using
* {@link DistributionFactory#createNormalDistribution(double, double)}.<p>
*
* <p>
* References:<p>

View File

@ -26,9 +26,6 @@ package org.apache.commons.math.distribution;
* library is to express these functions in terms of the number of failures in
* a Bernoulli experiment [2].
*
* Instances of PascalDistribution objects should be created using
* {@link DistributionFactory#createPascalDistribution(int, double)}.
*
* <p>
* References:
* <ol>

View File

@ -19,9 +19,6 @@ package org.apache.commons.math.distribution;
/**
* Student's t-Distribution.
*
* Instances of TDistribution objects should be created using
* {@link DistributionFactory#createTDistribution(double)}
*
* <p>
* References:
* <ul>

View File

@ -23,9 +23,6 @@ package org.apache.commons.math.distribution;
* <a href="http://mathworld.wolfram.com/WeibullDistribution.html">
* Weibull Distribution</a>, equations (1) and (2).
*
* Instances of WeibullDistribution objects should be created using
* {@link DistributionFactory#createWeibullDistribution(double, double)}
*
* <p>
* References:
* <ul>

View File

@ -37,7 +37,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
/** Creates the default discrete distribution instance to use in tests. */
public IntegerDistribution makeDistribution() {
return DistributionFactory.newInstance().createBinomialDistribution(10,0.70);
return new BinomialDistributionImpl(10,0.70);
}
/** Creates the default probability density test input values */
@ -77,7 +77,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
/** Test degenerate case p = 0 */
public void testDegenerate0() throws Exception {
setDistribution(DistributionFactory.newInstance().createBinomialDistribution(5,0.0d));
setDistribution(new BinomialDistributionImpl(5,0.0d));
setCumulativeTestPoints(new int[] {-1, 0, 1, 5, 10 });
setCumulativeTestValues(new double[] {0d, 1d, 1d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 10, 11});
@ -91,7 +91,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
/** Test degenerate case p = 1 */
public void testDegenerate1() throws Exception {
setDistribution(DistributionFactory.newInstance().createBinomialDistribution(5,1.0d));
setDistribution(new BinomialDistributionImpl(5,1.0d));
setCumulativeTestPoints(new int[] {-1, 0, 1, 2, 5, 10 });
setCumulativeTestValues(new double[] {0d, 0d, 0d, 0d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 2, 5, 10});

View File

@ -38,7 +38,7 @@ public class CauchyDistributionTest extends ContinuousDistributionAbstractTest
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createCauchyDistribution(1.2, 2.1);
return new CauchyDistributionImpl(1.2, 2.1);
}
/** Creates the default cumulative probability distribution test input values */

View File

@ -38,7 +38,7 @@ public class ChiSquareDistributionTest extends ContinuousDistributionAbstractTes
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createChiSquareDistribution(5.0);
return new ChiSquaredDistributionImpl(5.0);
}
/** Creates the default cumulative probability distribution test input values */
@ -76,7 +76,7 @@ public class ChiSquareDistributionTest extends ContinuousDistributionAbstractTes
//---------------------------- Additional test cases -------------------------
public void testSmallDf() throws Exception {
setDistribution(DistributionFactory.newInstance().createChiSquareDistribution(0.1d));
setDistribution(new ChiSquaredDistributionImpl(0.1d));
setTolerance(1E-4);
// quantiles computed using R version 1.8.1 (linux version)
setCumulativeTestPoints(new double[] {1.168926E-60, 1.168926E-40, 1.063132E-32,

View File

@ -17,6 +17,7 @@
package org.apache.commons.math.distribution;
import junit.framework.TestCase;
import org.apache.commons.math.TestUtils;
/**

View File

@ -1,377 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.distribution;
import junit.framework.TestCase;
/**
* @version $Revision$ $Date$
*/
public class DistributionFactoryImplTest extends TestCase {
/** */
private DistributionFactory factory;
/**
* Constructor for DistributionFactoryImplTest.
* @param name
*/
public DistributionFactoryImplTest(String name) {
super(name);
}
/**
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
super.setUp();
factory = new DistributionFactoryImpl();
}
/**
* @throws java.lang.Exception
*/
protected void tearDown() throws Exception {
factory = null;
super.tearDown();
}
public void testCreateChiSquareDistributionNegative(){
try {
factory.createChiSquareDistribution(-1.0);
fail("negative degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateChiSquareDistributionZero(){
try {
factory.createChiSquareDistribution(0.0);
fail("zero degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateChiSquareDistributionPositive(){
try {
factory.createChiSquareDistribution(1.0);
} catch (IllegalArgumentException ex) {
fail("positive degrees of freedom. IllegalArgumentException is not expected");
}
}
public void testCreateFDistributionNegativePositive(){
try {
factory.createFDistribution(-1.0, 1.0);
fail("negative degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateFDistributionZeroPositive(){
try {
factory.createFDistribution(0.0, 1.0);
fail("zero degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateFDistributionPositiveNegative(){
try {
factory.createFDistribution(1.0, -1.0);
fail("negative degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateFDistributionPositiveZero(){
try {
factory.createFDistribution(1.0, 0.0);
fail("zero degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateFDistributionPositivePositive(){
try {
factory.createFDistribution(1.0, 1.0);
} catch (IllegalArgumentException ex) {
fail("positive degrees of freedom. IllegalArgumentException is not expected");
}
}
public void testCreateExponentialDistributionNegative(){
try {
factory.createExponentialDistribution(-1.0);
fail("negative mean. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateExponentialDistributionZero(){
try {
factory.createExponentialDistribution(0.0);
fail("zero mean. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateExponentialDistributionPositive(){
try {
factory.createExponentialDistribution(1.0);
} catch (IllegalArgumentException ex) {
fail("positive mean. IllegalArgumentException is not expected");
}
}
public void testCreateGammaDistributionNegativePositive(){
try {
factory.createGammaDistribution(-1.0, 1.0);
fail("negative alpha. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateGammaDistributionZeroPositive(){
try {
factory.createGammaDistribution(0.0, 1.0);
fail("zero alpha. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateGammaDistributionPositiveNegative(){
try {
factory.createGammaDistribution(1.0, -1.0);
fail("negative beta. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateGammaDistributionPositiveZero(){
try {
factory.createGammaDistribution(1.0, 0.0);
fail("zero beta. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateGammaDistributionPositivePositive(){
try {
factory.createGammaDistribution(1.0, 1.0);
} catch (IllegalArgumentException ex) {
fail("positive alpah and beta. IllegalArgumentException is not expected");
}
}
public void testCreateTDistributionNegative(){
try {
factory.createTDistribution(-1.0);
fail("negative degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateTDistributionZero(){
try {
factory.createTDistribution(0.0);
fail("zero degrees of freedom. IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
}
public void testCreateTDistributionPositive(){
try {
factory.createTDistribution(1.0);
} catch (IllegalArgumentException ex) {
fail("positive degrees of freedom. IllegalArgumentException is not expected");
}
}
public void testBinomialDistributionNegativePositive(){
try {
factory.createBinomialDistribution(-1, 0.5);
fail("negative number of trials. IllegalArgumentException expected");
} catch (IllegalArgumentException ex ) {
}
}
public void testBinomialDistributionZeroPositive(){
try {
factory.createBinomialDistribution(0, 0.5);
} catch (IllegalArgumentException ex ) {
fail("zero number of trials. IllegalArgumentException is not expected");
}
}
public void testBinomialDistributionPositivePositive(){
try {
factory.createBinomialDistribution(10, 0.5);
} catch (IllegalArgumentException ex ) {
fail("positive number of trials. IllegalArgumentException is not expected");
}
}
public void testBinomialDistributionPositiveNegative(){
try {
factory.createBinomialDistribution(10, -0.5);
fail("negative probability of success. IllegalArgumentException expected");
} catch (IllegalArgumentException ex ) {
}
}
public void testBinomialDistributionPositiveZero(){
try {
factory.createBinomialDistribution(10, 0.0);
} catch (IllegalArgumentException ex ) {
fail("zero probability of success. IllegalArgumentException is not expected");
}
}
public void testBinomialDistributionPositiveOne(){
try {
factory.createBinomialDistribution(10, 1.0);
} catch (IllegalArgumentException ex ) {
fail("valid probability of success. IllegalArgumentException is not expected");
}
}
public void testBinomialDistributionPositiveTwo(){
try {
factory.createBinomialDistribution(10, 2.0);
fail("high probability of success. IllegalArgumentException expected");
} catch (IllegalArgumentException ex ) {
}
}
public void testHypergeometricDistributionNegativePositivePositive(){
try {
factory.createHypergeometricDistribution(-1, 10, 10);
fail("negative population size. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testHypergeometricDistributionZeroPositivePositive(){
try {
factory.createHypergeometricDistribution(0, 10, 10);
fail("zero population size. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testHypergeometricDistributionPositiveNegativePositive(){
try {
factory.createHypergeometricDistribution(20, -1, 10);
fail("negative number of successes. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testHypergeometricDistributionPositiveZeroPositive(){
try {
factory.createHypergeometricDistribution(20, 0, 10);
} catch(IllegalArgumentException ex) {
fail("valid number of successes. IllegalArgumentException is not expected");
}
}
public void testHypergeometricDistributionPositivePositiveNegative(){
try {
factory.createHypergeometricDistribution(20, 10, -1);
fail("negative sample size. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testHypergeometricDistributionPositivePositiveZero(){
try {
factory.createHypergeometricDistribution(20, 10, 0);
} catch(IllegalArgumentException ex) {
fail("valid sample size. IllegalArgumentException is not expected");
}
}
public void testHypergeometricDistributionSmallPopulationSize() {
try {
factory.createHypergeometricDistribution(5, 3, 10);
fail("sample size larger than population size. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testCauchyDistributionNegative() {
try {
factory.createCauchyDistribution(0.0, -1.0);
fail("invalid scale. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testCauchyDistributionZero() {
try {
factory.createCauchyDistribution(0.0, 0.0);
fail("invalid scale. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testWeibullDistributionNegativePositive() {
try {
factory.createWeibullDistribution(-1.0, 1.0);
fail("invalid shape. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testWeibullDistributionZeroPositive() {
try {
factory.createWeibullDistribution(0.0, 1.0);
fail("invalid shape. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testWeibullDistributionPositiveNegative() {
try {
factory.createWeibullDistribution(1.0, -1.0);
fail("invalid scale. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
public void testWeibullDistributionPositiveZero() {
try {
factory.createWeibullDistribution(1.0, 0.0);
fail("invalid scale. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
}
}

View File

@ -37,7 +37,7 @@ public class ExponentialDistributionTest extends ContinuousDistributionAbstractT
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createExponentialDistribution(5.0);
return new ExponentialDistributionImpl(5.0);
}
/** Creates the default cumulative probability distribution test input values */

View File

@ -38,7 +38,7 @@ public class FDistributionTest extends ContinuousDistributionAbstractTest {
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createFDistribution(5.0, 6.0);
return new FDistributionImpl(5.0, 6.0);
}
/** Creates the default cumulative probability distribution test input values */

View File

@ -38,7 +38,7 @@ public class GammaDistributionTest extends ContinuousDistributionAbstractTest {
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createGammaDistribution(4d, 2d);
return new GammaDistributionImpl(4d, 2d);
}
/** Creates the default cumulative probability distribution test input values */
@ -100,15 +100,13 @@ public class GammaDistributionTest extends ContinuousDistributionAbstractTest {
}
private void testProbability(double x, double a, double b, double expected) throws Exception {
DistributionFactory factory = DistributionFactory.newInstance();
GammaDistribution distribution = factory.createGammaDistribution( a, b );
GammaDistribution distribution = new GammaDistributionImpl( a, b );
double actual = distribution.cumulativeProbability(x);
assertEquals("probability for " + x, expected, actual, 10e-4);
}
private void testValue(double expected, double a, double b, double p) throws Exception {
DistributionFactory factory = DistributionFactory.newInstance();
GammaDistribution distribution = factory.createGammaDistribution( a, b );
GammaDistribution distribution = new GammaDistributionImpl( a, b );
double actual = distribution.inverseCumulativeProbability(p);
assertEquals("critical value for " + p, expected, actual, 10e-4);
}

View File

@ -40,7 +40,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
/** Creates the default discrete distribution instance to use in tests. */
public IntegerDistribution makeDistribution() {
return DistributionFactory.newInstance().createHypergeometricDistribution(10,5, 5);
return new HypergeometricDistributionImpl(10,5, 5);
}
/** Creates the default probability density test input values */
@ -80,7 +80,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
/** Verify that if there are no failures, mass is concentrated on sampleSize */
public void testDegenerateNoFailures() throws Exception {
setDistribution(DistributionFactory.newInstance().createHypergeometricDistribution(5,5,3));
setDistribution(new HypergeometricDistributionImpl(5,5,3));
setCumulativeTestPoints(new int[] {-1, 0, 1, 3, 10 });
setCumulativeTestValues(new double[] {0d, 0d, 0d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 3, 10});
@ -94,7 +94,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
/** Verify that if there are no successes, mass is concentrated on 0 */
public void testDegenerateNoSuccesses() throws Exception {
setDistribution(DistributionFactory.newInstance().createHypergeometricDistribution(5,0,3));
setDistribution(new HypergeometricDistributionImpl(5,0,3));
setCumulativeTestPoints(new int[] {-1, 0, 1, 3, 10 });
setCumulativeTestValues(new double[] {0d, 1d, 1d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 3, 10});
@ -108,7 +108,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
/** Verify that if sampleSize = populationSize, mass is concentrated on numberOfSuccesses */
public void testDegenerateFullSample() throws Exception {
setDistribution(DistributionFactory.newInstance().createHypergeometricDistribution(5,3,5));
setDistribution(new HypergeometricDistributionImpl(5,3,5));
setCumulativeTestPoints(new int[] {-1, 0, 1, 3, 10 });
setCumulativeTestValues(new double[] {0d, 0d, 0d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 3, 10});
@ -121,7 +121,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
}
public void testPopulationSize() {
HypergeometricDistribution dist = DistributionFactory.newInstance().createHypergeometricDistribution(5,3,5);
HypergeometricDistribution dist = new HypergeometricDistributionImpl(5,3,5);
try {
dist.setPopulationSize(-1);
fail("negative population size. IllegalArgumentException expected");

View File

@ -38,7 +38,7 @@ public class NormalDistributionTest extends ContinuousDistributionAbstractTest
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createNormalDistribution(2.1, 1.4);
return new NormalDistributionImpl(2.1, 1.4);
}
/** Creates the default cumulative probability distribution test input values */
@ -77,9 +77,9 @@ public class NormalDistributionTest extends ContinuousDistributionAbstractTest
public void testQuantiles() throws Exception {
verifyQuantiles();
setDistribution(DistributionFactory.newInstance().createNormalDistribution(0, 1));
setDistribution(new NormalDistributionImpl(0, 1));
verifyQuantiles();
setDistribution(DistributionFactory.newInstance().createNormalDistribution(0, 0.1));
setDistribution(new NormalDistributionImpl(0, 0.1));
verifyQuantiles();
}

View File

@ -37,7 +37,7 @@ public class PascalDistributionTest extends IntegerDistributionAbstractTest {
/** Creates the default discrete distribution instance to use in tests. */
public IntegerDistribution makeDistribution() {
return DistributionFactory.newInstance().createPascalDistribution(10,0.70);
return new PascalDistributionImpl(10,0.70);
}
/** Creates the default probability density test input values */
@ -77,7 +77,7 @@ public class PascalDistributionTest extends IntegerDistributionAbstractTest {
/** Test degenerate case p = 0 */
public void testDegenerate0() throws Exception {
setDistribution(DistributionFactory.newInstance().createPascalDistribution(5,0.0d));
setDistribution(new PascalDistributionImpl(5,0.0d));
setCumulativeTestPoints(new int[] {-1, 0, 1, 5, 10 });
setCumulativeTestValues(new double[] {0d, 0d, 0d, 0d, 0d});
setDensityTestPoints(new int[] {-1, 0, 1, 10, 11});
@ -91,7 +91,7 @@ public class PascalDistributionTest extends IntegerDistributionAbstractTest {
/** Test degenerate case p = 1 */
public void testDegenerate1() throws Exception {
setDistribution(DistributionFactory.newInstance().createPascalDistribution(5,1.0d));
setDistribution(new PascalDistributionImpl(5,1.0d));
setCumulativeTestPoints(new int[] {-1, 0, 1, 2, 5, 10 });
setCumulativeTestValues(new double[] {0d, 1d, 1d, 1d, 1d, 1d});
setDensityTestPoints(new int[] {-1, 0, 1, 2, 5, 10});

View File

@ -43,8 +43,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
* Creates the default discrete distribution instance to use in tests.
*/
public IntegerDistribution makeDistribution() {
return DistributionFactory.newInstance().createPoissonDistribution
(DEFAULT_TEST_POISSON_PARAMETER);
return new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
}
/**
@ -105,7 +104,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
* P(9900 &le; X &le; 10200) for X = Po(10000)
*/
public void testNormalApproximateProbability() throws Exception {
PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(100);
PoissonDistribution dist = new PoissonDistributionImpl(100);
double result = dist.normalApproximateProbability(110)
- dist.normalApproximateProbability(89);
assertEquals(0.706281887248, result, 1E-10);
@ -120,13 +119,13 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
* @throws Exception
*/
public void testDegenerateInverseCumulativeProbability() throws Exception {
PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(DEFAULT_TEST_POISSON_PARAMETER);
PoissonDistribution dist = new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
assertEquals(Integer.MAX_VALUE, dist.inverseCumulativeProbability(1.0d));
assertEquals(-1, dist.inverseCumulativeProbability(0d));
}
public void testMean() {
PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(DEFAULT_TEST_POISSON_PARAMETER);
PoissonDistribution dist = new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
try {
dist.setMean(-1);
fail("negative mean. IllegalArgumentException expected");
@ -138,7 +137,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
}
public void testLargeMeanCumulativeProbability() {
PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
PoissonDistribution dist = new PoissonDistributionImpl(1.0);
double mean = 1.0;
while (mean <= 10000000.0) {
dist.setMean(mean);
@ -159,7 +158,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
}
public void testLargeMeanInverseCumulativeProbability() {
PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
PoissonDistribution dist = new PoissonDistributionImpl(1.0);
double mean = 1.0;
while (mean <= 10000000.0) {
dist.setMean(mean);

View File

@ -37,7 +37,7 @@ public class TDistributionTest extends ContinuousDistributionAbstractTest {
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createTDistribution(5.0);
return new TDistributionImpl(5.0);
}
/** Creates the default cumulative probability distribution test input values */
@ -67,13 +67,12 @@ public class TDistributionTest extends ContinuousDistributionAbstractTest {
*/
public void testCumulativeProbabilityAgaintStackOverflow() throws Exception {
TDistributionImpl td = new TDistributionImpl(5.);
double est;
est = td.cumulativeProbability(.1);
est = td.cumulativeProbability(.01);
td.cumulativeProbability(.1);
td.cumulativeProbability(.01);
}
public void testSmallDf() throws Exception {
setDistribution(DistributionFactory.newInstance().createTDistribution(1d));
setDistribution(new TDistributionImpl(1d));
setTolerance(1E-4);
// quantiles computed using R version 1.8.1 (linux version)
setCumulativeTestPoints(new double[] {-318.3088, -31.82052, -12.70620, -6.313752,

View File

@ -38,7 +38,7 @@ public class WeibullDistributionTest extends ContinuousDistributionAbstractTest
/** Creates the default continuous distribution instance to use in tests. */
public ContinuousDistribution makeDistribution() {
return DistributionFactory.newInstance().createWeibullDistribution(1.2, 2.1);
return new WeibullDistributionImpl(1.2, 2.1);
}
/** Creates the default cumulative probability distribution test input values */