svn commit: r180065 - in /jakarta/commons/proper/math/trunk: src/java/org/apache/commons/math/distribution/ src/java/org/apache/commons/math/stat/inference/ src/test/org/apache/commons/math/stat/inference/ xdocs/ xdocs/userguide/

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r180065 - in /jakarta/commons/proper/math/trunk: src/java/org/apache/commons/math/distribution/ src/java/org/apache/commons/math/stat/inference/ src/test/org/apache/commons/math/stat/inference/ xdocs/ xdocs/userguide/

Phil Steitz-4
Author: psteitz
Date: Sat Jun  4 20:58:14 2005
New Revision: 180065

URL: http://svn.apache.org/viewcvs?rev=180065&view=rev
Log:
Added factory for TTest, ChiSquareTest and TestUtils class with
static methods to create instances and execute tests.
PR #32663


Added:
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactory.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactoryImpl.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestUtils.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareFactoryTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestFactoryTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java
Modified:
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/distribution/DistributionFactory.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestTest.java
    jakarta/commons/proper/math/trunk/xdocs/changes.xml
    jakarta/commons/proper/math/trunk/xdocs/userguide/stat.xml

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/distribution/DistributionFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/distribution/DistributionFactory.java?rev=180065&r1=180064&r2=180065&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/distribution/DistributionFactory.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/distribution/DistributionFactory.java Sat Jun  4 20:58:14 2005
@@ -62,7 +62,7 @@
             DiscoverClass dc = new DiscoverClass();
             factory = (DistributionFactory) dc.newInstance(
                 DistributionFactory.class,
-                "org.apache.commons.math.distribution.DistributionFactoryImpl");
+                "org.apache.commons.math.distribution.TestFactoryImpl");
         } catch(Throwable t) {
             return new DistributionFactoryImpl();
         }

Added: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactory.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactory.java (added)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactory.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+import org.apache.commons.discovery.tools.DiscoverClass;
+
+/**
+ * Abstract factory to create inference test instances.
+ *
+ * @version $Revision$ $Date$
+ */
+public abstract class TestFactory {
+    /**
+     * Default constructor.
+     */
+    protected TestFactory() {
+        super();
+    }
+    
+    /**
+     * Create an instance of a <code>TestFactory</code>
+     *
+     * @return a new factory.
+     */
+    public static TestFactory newInstance() {
+        TestFactory factory = null;
+        try {
+            DiscoverClass dc = new DiscoverClass();
+            factory = (TestFactory) dc.newInstance(
+                    TestFactory.class,
+            "org.apache.commons.math.stat.inference.TestFactoryImpl");
+        } catch(Throwable t) {
+            return new TestFactoryImpl();
+        }
+        return factory;
+    }
+    
+    /**
+     * Create a TTest instance.
+     *
+     * @return a new TTest instance
+     */
+    public abstract TTest createTTest();
+    
+    /**
+     * Create a ChiSquareTest instance.
+     *
+     * @return a new ChiSquareTest instance
+     */
+    public abstract ChiSquareTest createChiSquareTest();  
+}

Added: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactoryImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactoryImpl.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactoryImpl.java (added)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestFactoryImpl.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+
+/**
+ * A concrete inference test factory.  This is the default factory used by
+ * Commons-Math.
+ *  
+ * @version $Revision$ $Date$
+ */
+public class TestFactoryImpl extends TestFactory {
+
+    /**
+     * Default constructor.
+     */
+    public TestFactoryImpl() {
+        super();
+    }
+    
+     /**
+     * Create a TTest instance.
+     *
+     * @return a new TTest instance
+     */
+    public TTest createTTest() {      
+        return new TTestImpl();
+    }
+    
+    /**
+     * Create a ChiSquareTest instance.
+     *
+     * @return a new ChiSquareTest instance
+     */
+    public ChiSquareTest createChiSquareTest() {
+        return new ChiSquareTestImpl();
+    }
+    
+}

Added: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestUtils.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestUtils.java (added)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/inference/TestUtils.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+
+import org.apache.commons.math.MathException;
+import org.apache.commons.math.stat.descriptive.StatisticalSummary;
+
+/**
+ * A collection of static methods to create inference test instances or to
+ * perform inference tests.
+ *
+ * @version $Revision$ $Date$
+ */
+public class TestUtils  {
+    /**
+     * Prevent instantiation.
+     */
+    protected TestUtils() {
+        super();
+    }
+    
+    /** Singleton TTest instance initialized using configured factory */
+    private static TTest tTest = TestFactory.newInstance().createTTest();
+  
+    /** Singleton ChiSquareTest instance initialized using configured factory */
+    private static ChiSquareTest chiSquareTest =
+        TestFactory.newInstance().createChiSquareTest();
+    
+    /**
+     * Return a (singleton) TTest instance.  Does not create a new instance.
+     *
+     * @return a TTest instance
+     */
+    public static TTest getTTest() {
+        return tTest;
+    }
+    
+    /**
+     * Return a (singleton) ChiSquareTest instance.  Does not create a new instance.
+     *
+     * @return a ChiSquareTest instance
+     */
+    public static ChiSquareTest getChiSquareTest() {
+        return chiSquareTest;
+    }
+    
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(double[], double[])
+     */
+    public static double homoscedasticT(double[] sample1, double[] sample2)
+        throws IllegalArgumentException {
+        return tTest.homoscedasticT(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double homoscedasticT(StatisticalSummary sampleStats1,
+        StatisticalSummary sampleStats2)
+        throws IllegalArgumentException {
+        return tTest.homoscedasticT(sampleStats1, sampleStats2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[], double)
+     */
+    public static boolean homoscedasticTTest(double[] sample1, double[] sample2,
+            double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest. homoscedasticTTest(sample1, sample2, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[])
+     */
+    public static double homoscedasticTTest(double[] sample1, double[] sample2)
+        throws IllegalArgumentException, MathException {
+        return tTest.homoscedasticTTest(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double homoscedasticTTest(StatisticalSummary sampleStats1,
+        StatisticalSummary sampleStats2)
+        throws IllegalArgumentException, MathException {
+        return tTest.homoscedasticTTest(sampleStats1, sampleStats2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#pairedT(double[], double[])
+     */
+    public static double pairedT(double[] sample1, double[] sample2)
+        throws IllegalArgumentException, MathException {
+        return tTest.pairedT(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[], double)
+     */
+    public static boolean pairedTTest(double[] sample1, double[] sample2,
+        double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest.pairedTTest(sample1, sample2, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[])
+     */
+    public static double pairedTTest(double[] sample1, double[] sample2)
+        throws IllegalArgumentException, MathException {
+        return tTest.pairedTTest(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#t(double, double[])
+     */
+    public static double t(double mu, double[] observed)
+        throws IllegalArgumentException {
+        return tTest.t(mu, observed);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#t(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double t(double mu, StatisticalSummary sampleStats)
+        throws IllegalArgumentException {
+        return tTest.t(mu, sampleStats);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#t(double[], double[])
+     */
+    public static double t(double[] sample1, double[] sample2)
+        throws IllegalArgumentException {
+        return tTest.t(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#t(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double t(StatisticalSummary sampleStats1,
+            StatisticalSummary sampleStats2)
+        throws IllegalArgumentException {
+        return tTest.t(sampleStats1, sampleStats2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[], double)
+     */
+    public static boolean tTest(double mu, double[] sample, double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(mu, sample, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[])
+     */
+    public static double tTest(double mu, double[] sample)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(mu, sample);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)
+     */
+    public static boolean tTest(double mu, StatisticalSummary sampleStats,
+        double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest. tTest(mu, sampleStats, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double tTest(double mu, StatisticalSummary sampleStats)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(mu, sampleStats);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[], double)
+     */
+    public static boolean tTest(double[] sample1, double[] sample2, double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(sample1, sample2, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[])
+     */
+    public static double tTest(double[] sample1, double[] sample2)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(sample1, sample2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)
+     */
+    public static boolean tTest(StatisticalSummary sampleStats1,
+        StatisticalSummary sampleStats2, double alpha)
+        throws IllegalArgumentException, MathException {
+        return tTest. tTest(sampleStats1, sampleStats2, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
+     */
+    public static double tTest(StatisticalSummary sampleStats1,
+        StatisticalSummary sampleStats2)
+        throws IllegalArgumentException, MathException {
+        return tTest.tTest(sampleStats1, sampleStats2);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(double[], long[])
+     */
+    public static double chiSquare(double[] expected, long[] observed)
+        throws IllegalArgumentException {
+        return chiSquareTest.chiSquare(expected, observed);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(long[][])
+     */
+    public static double chiSquare(long[][] counts)
+        throws IllegalArgumentException {
+        return chiSquareTest.chiSquare(counts);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[], double)
+     */
+    public static boolean chiSquareTest(double[] expected, long[] observed,
+        double alpha)
+        throws IllegalArgumentException, MathException {
+        return chiSquareTest.chiSquareTest(expected, observed, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[])
+     */
+    public static double chiSquareTest(double[] expected, long[] observed)
+        throws IllegalArgumentException, MathException {
+        return chiSquareTest.chiSquareTest(expected, observed);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][], double)
+     */
+    public static boolean chiSquareTest(long[][] counts, double alpha)
+        throws IllegalArgumentException, MathException {
+        return chiSquareTest. chiSquareTest(counts, alpha);
+    }
+
+    /**
+     * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][])
+     */
+    public static double chiSquareTest(long[][] counts)
+        throws IllegalArgumentException, MathException {
+        return chiSquareTest. chiSquareTest(counts);
+    }
+
+}

Added: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareFactoryTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareFactoryTest.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareFactoryTest.java (added)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareFactoryTest.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test cases for the ChiSquareTestFactory.
+ *
+ * @version $Revision$ $Date$
+ */
+
+public class ChiSquareFactoryTest extends ChiSquareTestTest {
+
+    public ChiSquareFactoryTest(String name) {
+        super(name);
+    }
+    
+    public void setUp() {
+        testStatistic = TestUtils.getChiSquareTest();
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ChiSquareFactoryTest.class);
+        suite.setName("ChiSquareTestFactory Tests");
+        return suite;
+    }
+}

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java?rev=180065&r1=180064&r2=180065&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java Sat Jun  4 20:58:14 2005
@@ -25,9 +25,9 @@
  * @version $Revision$ $Date$
  */
 
-public final class ChiSquareTestTest extends TestCase {
+public class ChiSquareTestTest extends TestCase {
 
-    private ChiSquareTestImpl testStatistic = new ChiSquareTestImpl();
+    protected ChiSquareTest testStatistic = new ChiSquareTestImpl();
 
     public ChiSquareTestTest(String name) {
         super(name);

Added: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestFactoryTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestFactoryTest.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestFactoryTest.java (added)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestFactoryTest.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test cases for the TTestTestFactory.
+ *
+ * @version $Revision$ $Date$
+ */
+
+public class TTestFactoryTest extends TTestTest {
+
+    public TTestFactoryTest(String name) {
+        super(name);
+    }
+    
+    public void setUp() {
+        testStatistic = TestUtils.getTTest();
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(TTestFactoryTest.class);
+        suite.setName("TTestFactory Tests");
+        return suite;
+    }
+}

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestTest.java?rev=180065&r1=180064&r2=180065&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TTestTest.java Sat Jun  4 20:58:14 2005
@@ -26,9 +26,9 @@
  * @version $Revision$ $Date$
  */
 
-public final class TTestTest extends TestCase {
+public class TTestTest extends TestCase {
 
-    private TTestImpl testStatistic = new TTestImpl();
+    protected TTest testStatistic = new TTestImpl();
     
     private double[] tooShortObs = { 1.0 };
     private double[] nullObserved = null;

Added: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java?rev=180065&view=auto
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java (added)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java Sat Jun  4 20:58:14 2005
@@ -0,0 +1,446 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.stat.inference;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.math.stat.descriptive.SummaryStatistics;
+/**
+ * Test cases for the TestUtils class.
+ *
+ * @version $Revision$ $Date$
+ */
+
+public class TestUtilsTest extends TestCase {
+
+    public TestUtilsTest(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(TestUtilsTest.class);
+        suite.setName("TestUtils Tests");
+        return suite;
+    }
+
+    public void testChiSquare() throws Exception {
+        
+        // Target values computed using R version 1.8.1
+        // Some assembly required ;-)  
+        //      Use sum((obs - exp)^2/exp) for the chi-square statistic and
+        //      1 - pchisq(sum((obs - exp)^2/exp), length(obs) - 1) for the p-value
+        
+        long[] observed = {10, 9, 11};
+        double[] expected = {10, 10, 10};
+        assertEquals("chi-square statistic", 0.2,  TestUtils.chiSquare(expected, observed), 10E-12);
+        assertEquals("chi-square p-value", 0.904837418036, TestUtils.chiSquareTest(expected, observed), 1E-10);
+        
+        long[] observed1 = { 500, 623, 72, 70, 31 };
+        double[] expected1 = { 485, 541, 82, 61, 37 };
+        assertEquals( "chi-square test statistic", 16.4131070362, TestUtils.chiSquare(expected1, observed1), 1E-10);
+        assertEquals("chi-square p-value", 0.002512096, TestUtils.chiSquareTest(expected1, observed1), 1E-9);
+        assertTrue("chi-square test reject", TestUtils.chiSquareTest(expected1, observed1, 0.003));
+        assertTrue("chi-square test accept", !TestUtils.chiSquareTest(expected1, observed1, 0.002));
+
+        try {
+            TestUtils.chiSquareTest(expected1, observed1, 95);
+            fail("alpha out of range, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        long[] tooShortObs = { 0 };
+        double[] tooShortEx = { 1 };
+        try {
+            TestUtils.chiSquare(tooShortEx, tooShortObs);
+            fail("arguments too short, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        // unmatched arrays
+        long[] unMatchedObs = { 0, 1, 2, 3 };
+        double[] unMatchedEx = { 1, 1, 2 };
+        try {
+            TestUtils.chiSquare(unMatchedEx, unMatchedObs);
+            fail("arrays have different lengths, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        // 0 expected count
+        expected[0] = 0;
+        try {
+            TestUtils.chiSquareTest(expected, observed, .01);
+            fail("bad expected count, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        // negative observed count
+        expected[0] = 1;
+        observed[0] = -1;
+        try {
+            TestUtils.chiSquareTest(expected, observed, .01);
+            fail("bad expected count, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+    }
+
+    public void testChiSquareIndependence() throws Exception {
+        
+        // Target values computed using R version 1.8.1
+        
+        long[][] counts = { {40, 22, 43}, {91, 21, 28}, {60, 10, 22}};
+        assertEquals( "chi-square test statistic", 22.709027688, TestUtils.chiSquare(counts), 1E-9);
+        assertEquals("chi-square p-value", 0.000144751460134, TestUtils.chiSquareTest(counts), 1E-9);
+        assertTrue("chi-square test reject", TestUtils.chiSquareTest(counts, 0.0002));
+        assertTrue("chi-square test accept", !TestUtils.chiSquareTest(counts, 0.0001));    
+        
+        long[][] counts2 = {{10, 15}, {30, 40}, {60, 90} };
+        assertEquals( "chi-square test statistic", 0.168965517241, TestUtils.chiSquare(counts2), 1E-9);
+        assertEquals("chi-square p-value",0.918987499852, TestUtils.chiSquareTest(counts2), 1E-9);
+        assertTrue("chi-square test accept", !TestUtils.chiSquareTest(counts2, 0.1));
+        
+        // ragged input array
+        long[][] counts3 = { {40, 22, 43}, {91, 21, 28}, {60, 10}};
+        try {
+            TestUtils.chiSquare(counts3);
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        // insufficient data
+        long[][] counts4 = {{40, 22, 43}};
+        try {
+            TestUtils.chiSquare(counts4);
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        long[][] counts5 = {{40}, {40}, {30}, {10}};
+        try {
+            TestUtils.chiSquare(counts5);
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        // negative counts
+        long[][] counts6 = {{10, -2}, {30, 40}, {60, 90} };
+        try {
+            TestUtils.chiSquare(counts6);
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        // bad alpha
+        try {
+            TestUtils.chiSquareTest(counts, 0);
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    
+    public void testChiSquareLargeTestStatistic() throws Exception {
+        double[] exp = new double[] {
+                3389119.5, 649136.6, 285745.4, 25357364.76, 11291189.78, 543628.0,
+                232921.0, 437665.75
+        };
+
+        long[] obs = new long[] {
+                2372383, 584222, 257170, 17750155, 7903832, 489265, 209628, 393899
+        };
+        org.apache.commons.math.stat.inference.ChiSquareTestImpl csti =
+            new org.apache.commons.math.stat.inference.ChiSquareTestImpl();
+        double cst = csti.chiSquareTest(exp, obs);
+        assertEquals("chi-square p-value", 0.0, cst, 1E-3);
+        assertEquals( "chi-square test statistic",
+                3624883.342907764, TestUtils.chiSquare(exp, obs), 1E-9);
+    }
+    
+    /** Contingency table containing zeros - PR # 32531 */
+    public void testChiSquareZeroCount() throws Exception {
+        // Target values computed using R version 1.8.1
+        long[][] counts = { {40, 0, 4}, {91, 1, 2}, {60, 2, 0}};
+        assertEquals( "chi-square test statistic", 9.67444662263,
+                TestUtils.chiSquare(counts), 1E-9);
+        assertEquals("chi-square p-value", 0.0462835770603,
+                TestUtils.chiSquareTest(counts), 1E-9);      
+    }
+    
+    private double[] tooShortObs = { 1.0 };
+    private double[] nullObserved = null;
+    private double[] emptyObs = {};
+    private SummaryStatistics emptyStats = SummaryStatistics.newInstance();  
+    private SummaryStatistics nullStats = null;  
+    SummaryStatistics tooShortStats = null;  
+
+    public void testOneSampleT() throws Exception {
+        double[] observed =
+            {93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0,  88.0, 98.0, 94.0, 101.0, 92.0, 95.0 };
+        double mu = 100.0;
+        SummaryStatistics sampleStats = null;
+        sampleStats = SummaryStatistics.newInstance();
+        for (int i = 0; i < observed.length; i++) {
+            sampleStats.addValue(observed[i]);
+        }
+
+        // Target comparison values computed using R version 1.8.1 (Linux version)
+        assertEquals("t statistic",  -2.81976445346,
+                TestUtils.t(mu, observed), 10E-10);
+        assertEquals("t statistic",  -2.81976445346,
+                TestUtils.t(mu, sampleStats), 10E-10);
+        assertEquals("p value", 0.0136390585873,
+                TestUtils.tTest(mu, observed), 10E-10);
+        assertEquals("p value", 0.0136390585873,
+                TestUtils.tTest(mu, sampleStats), 10E-10);
+
+        try {
+            TestUtils.t(mu, nullObserved);
+            fail("arguments too short, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            TestUtils.t(mu, nullStats);
+            fail("arguments too short, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            TestUtils.t(mu, emptyObs);
+            fail("arguments too short, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        try {
+            TestUtils.t(mu, emptyStats);
+            fail("arguments too short, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            TestUtils.t(mu, tooShortObs);
+            fail("insufficient data to compute t statistic, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // exptected
+        }
+        try {
+            TestUtils.tTest(mu, tooShortObs);
+            fail("insufficient data to perform t test, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+
+        try {
+            TestUtils.t(mu, tooShortStats);
+            fail("insufficient data to compute t statistic, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // exptected
+        }
+        try {
+            TestUtils.tTest(mu, tooShortStats);
+            fail("insufficient data to perform t test, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // exptected
+        }  
+    }
+    
+    public void testOneSampleTTest() throws Exception {
+        double[] oneSidedP =
+            {2d, 0d, 6d, 6d, 3d, 3d, 2d, 3d, -6d, 6d, 6d, 6d, 3d, 0d, 1d, 1d, 0d, 2d, 3d, 3d };
+        SummaryStatistics oneSidedPStats = SummaryStatistics.newInstance();    
+        for (int i = 0; i < oneSidedP.length; i++) {
+            oneSidedPStats.addValue(oneSidedP[i]);
+        }
+        // Target comparison values computed using R version 1.8.1 (Linux version)
+        assertEquals("one sample t stat", 3.86485535541,
+                TestUtils.t(0d, oneSidedP), 10E-10);
+        assertEquals("one sample t stat", 3.86485535541,
+                TestUtils.t(0d, oneSidedPStats),1E-10);
+        assertEquals("one sample p value", 0.000521637019637,
+                TestUtils.tTest(0d, oneSidedP) / 2d, 10E-10);
+        assertEquals("one sample p value", 0.000521637019637,
+                TestUtils.tTest(0d, oneSidedPStats) / 2d, 10E-5);
+        assertTrue("one sample t-test reject", TestUtils.tTest(0d, oneSidedP, 0.01));
+        assertTrue("one sample t-test reject", TestUtils.tTest(0d, oneSidedPStats, 0.01));
+        assertTrue("one sample t-test accept", !TestUtils.tTest(0d, oneSidedP, 0.0001));
+        assertTrue("one sample t-test accept", !TestUtils.tTest(0d, oneSidedPStats, 0.0001));
+        
+        try {
+            TestUtils.tTest(0d, oneSidedP, 95);
+            fail("alpha out of range, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // exptected
+        }  
+        
+        try {
+            TestUtils.tTest(0d, oneSidedPStats, 95);
+            fail("alpha out of range, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+    }
+    
+    public void testTwoSampleTHeterscedastic() throws Exception {
+        double[] sample1 = { 7d, -4d, 18d, 17d, -3d, -5d, 1d, 10d, 11d, -2d };
+        double[] sample2 = { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
+        SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();  
+        for (int i = 0; i < sample1.length; i++) {
+            sampleStats1.addValue(sample1[i]);
+        }
+        SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();    
+        for (int i = 0; i < sample2.length; i++) {
+            sampleStats2.addValue(sample2[i]);
+        }
+        
+        // Target comparison values computed using R version 1.8.1 (Linux version)
+        assertEquals("two sample heteroscedastic t stat", 1.60371728768,
+                TestUtils.t(sample1, sample2), 1E-10);
+        assertEquals("two sample heteroscedastic t stat", 1.60371728768,
+                TestUtils.t(sampleStats1, sampleStats2), 1E-10);
+        assertEquals("two sample heteroscedastic p value", 0.128839369622,
+                TestUtils.tTest(sample1, sample2), 1E-10);
+        assertEquals("two sample heteroscedastic p value", 0.128839369622,
+                TestUtils.tTest(sampleStats1, sampleStats2), 1E-10);    
+        assertTrue("two sample heteroscedastic t-test reject",
+                TestUtils.tTest(sample1, sample2, 0.2));
+        assertTrue("two sample heteroscedastic t-test reject",
+                TestUtils.tTest(sampleStats1, sampleStats2, 0.2));
+        assertTrue("two sample heteroscedastic t-test accept",
+                !TestUtils.tTest(sample1, sample2, 0.1));
+        assertTrue("two sample heteroscedastic t-test accept",
+                !TestUtils.tTest(sampleStats1, sampleStats2, 0.1));
+        
+        try {
+            TestUtils.tTest(sample1, sample2, .95);
+            fail("alpha out of range, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        try {
+            TestUtils.tTest(sampleStats1, sampleStats2, .95);
+            fail("alpha out of range, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        try {
+            TestUtils.tTest(sample1, tooShortObs, .01);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        try {
+            TestUtils.tTest(sampleStats1, tooShortStats, .01);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        try {
+            TestUtils.tTest(sample1, tooShortObs);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        try {
+            TestUtils.tTest(sampleStats1, tooShortStats);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }  
+        
+        try {
+            TestUtils.t(sample1, tooShortObs);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        
+        try {
+            TestUtils.t(sampleStats1, tooShortStats);
+            fail("insufficient data, IllegalArgumentException expected");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    public void testTwoSampleTHomoscedastic() throws Exception {
+        double[] sample1 ={2, 4, 6, 8, 10, 97};
+        double[] sample2 = {4, 6, 8, 10, 16};
+        SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();  
+        for (int i = 0; i < sample1.length; i++) {
+            sampleStats1.addValue(sample1[i]);
+        }
+        SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();    
+        for (int i = 0; i < sample2.length; i++) {
+            sampleStats2.addValue(sample2[i]);
+        }
+        
+        // Target comparison values computed using R version 1.8.1 (Linux version)
+        assertEquals("two sample homoscedastic t stat", 0.73096310086,
+                TestUtils.homoscedasticT(sample1, sample2), 10E-11);
+        assertEquals("two sample homoscedastic p value", 0.4833963785,
+                TestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);    
+        assertTrue("two sample homoscedastic t-test reject",
+                TestUtils.homoscedasticTTest(sample1, sample2, 0.49));
+        assertTrue("two sample homoscedastic t-test accept",
+                !TestUtils.homoscedasticTTest(sample1, sample2, 0.48));
+    }
+    
+    public void testSmallSamples() throws Exception {
+        double[] sample1 = {1d, 3d};
+        double[] sample2 = {4d, 5d};        
+        
+        // Target values computed using R, version 1.8.1 (linux version)
+        assertEquals(-2.2360679775, TestUtils.t(sample1, sample2),
+                1E-10);
+        assertEquals(0.198727388935, TestUtils.tTest(sample1, sample2),
+                1E-10);
+    }
+    
+    public void testPaired() throws Exception {
+        double[] sample1 = {1d, 3d, 5d, 7d};
+        double[] sample2 = {0d, 6d, 11d, 2d};
+        double[] sample3 = {5d, 7d, 8d, 10d};
+        double[] sample4 = {0d, 2d};
+        
+        // Target values computed using R, version 1.8.1 (linux version)
+        assertEquals(-0.3133, TestUtils.pairedT(sample1, sample2), 1E-4);
+        assertEquals(0.774544295819, TestUtils.pairedTTest(sample1, sample2), 1E-10);
+        assertEquals(0.001208, TestUtils.pairedTTest(sample1, sample3), 1E-6);
+        assertFalse(TestUtils.pairedTTest(sample1, sample3, .001));
+        assertTrue(TestUtils.pairedTTest(sample1, sample3, .002));    
+    }
+}

Modified: jakarta/commons/proper/math/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/xdocs/changes.xml?rev=180065&r1=180064&r2=180065&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/math/trunk/xdocs/changes.xml Sat Jun  4 20:58:14 2005
@@ -39,6 +39,10 @@
   <body>
     <release version="1.1" date="In Development"  
        description="Jakarta Commons Math 1.1 - Development">
+      <action dev="psteitz" type="update" issue="32663"  due-to="Mary Ellen Foster">
+        Added factories for TTest, ChiSquareTest and TestUtils class with
+        static methods to create instances and execute tests.
+      </action>
       <action dev="psteitz" type="update" issue="35042"  due-to="Paul Field">
         Eliminated repeated endpoint function evalutations in BrentSolver, SecantSolver.
       </action>

Modified: jakarta/commons/proper/math/trunk/xdocs/userguide/stat.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/xdocs/userguide/stat.xml?rev=180065&r1=180064&r2=180065&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/xdocs/userguide/stat.xml (original)
+++ jakarta/commons/proper/math/trunk/xdocs/userguide/stat.xml Sat Jun  4 20:58:14 2005
@@ -394,7 +394,25 @@
           Chi-Square</a> test statistics as well as
           <a href="http://www.cas.lancs.ac.uk/glossary_v1.1/hyptest.html#pvalue">
           p-values</a> associated with <code>t-</code> and
-          <code>Chi-Square</code> tests.
+          <code>Chi-Square</code> tests.  The interfaces are
+          <a href="../apidocs/org/apache/commons/math/stat/inference/TTest.html">
+          TTest</a> and
+          <a href="../apidocs/org/apache/commons/math/stat/inference/ChiSquareTest.html">
+          ChiSquareTest</a>, with
+          provided implementations
+          <a href="../apidocs/org/apache/commons/math/stat/inference/TTestImpl.html">
+          TTestImpl</a> and
+          <a href="../apidocs/org/apache/commons/math/stat/inference/ChiSquareTestImpl.html">
+          ChiSquareTestImpl</a>.
+          Abstract and default factories are provided, with configuration
+          optional using commons-discovery to specify the concrete factory.  The
+          <a href="../apidocs/org/apache/commons/math/stat/inference/TestUtils.html">
+          TestUtils</a> class provides static methods to get test instances or
+          to compute test statistics directly.  The examples below all use the
+          static methods in <code>TestUtils</code> to execute tests.  To get
+          test object instances, either use e.g.,
+          <code>TestUtils.getTTest()</code> or use the factory directly, e.g.,
+          <code>TestFactory.newInstance().createChiSquareTest()</code>.
         </p>
         <p>
           <strong>Implementation Notes</strong>
@@ -442,8 +460,7 @@
           <source>
 double[] observed = {1d, 2d, 3d};
 double mu = 2.5d;
-TTestImpl testStatistic = new TTestImpl();
-System.out.println(testStatistic.t(mu, observed);
+System.out.println(TestUtils.t(mu, observed);
           </source>
           The code above will display the t-statisitic associated with a one-sample
            t-test comparing the mean of the <code>observed</code> values against
@@ -460,7 +477,7 @@
 for (int i = 0; i &lt; observed.length; i++) {
     sampleStats.addValue(observed[i]);
 }
-System.out.println(testStatistic.t(mu, observed);
+System.out.println(TestUtils.t(mu, observed);
 </source>
            </dd>
            <dd>To compute the p-value associated with the null hypothesis that the mean
@@ -469,8 +486,7 @@
             <source>
 double[] observed = {1d, 2d, 3d};
 double mu = 2.5d;
-TTestImpl testStatistic = new TTestImpl();
-System.out.println(testStatistic.tTest(mu, observed);
+System.out.println(TestUtils.tTest(mu, observed);
            </source>
           The snippet above will display the p-value associated with the null
           hypothesis that the mean of the population from which the
@@ -478,7 +494,7 @@
           </dd>
           <dd>To perform the test using a fixed significance level, use:
           <source>
-testStatistic.tTest(mu, observed, alpha);  
+TestUtils.tTest(mu, observed, alpha);  
           </source>
           where <code>0 &lt; alpha &lt; 0.5</code> is the significance level of
           the test.  The boolean value returned will be <code>true</code> iff the
@@ -495,24 +511,23 @@
           <p>
           To compute the t-statistic:
           <source>
-TTestImpl testStatistic = new TTestImpl();
-testStatistic.pairedT(sample1, sample2);
+TestUtils.pairedT(sample1, sample2);
           </source>
            </p>
            <p>
            To compute the p-value:
            <source>
-testStatistic.pairedTTest(sample1, sample2);
+TestUtils.pairedTTest(sample1, sample2);
            </source>
            </p>
            <p>
            To perform a fixed significance level test with alpha = .05:
            <source>
-testStatistic.pairedTTest(sample1, sample2, .05);    
+TestUtils.pairedTTest(sample1, sample2, .05);    
            </source>
            </p>
            The last example will return <code>true</code> iff the p-value
-           returned by <code>testStatistic.pairedTTest(sample1, sample2)</code>
+           returned by <code>TestUtils.pairedTTest(sample1, sample2)</code>
            is less than <code>.05</code>
            </dd>
            <dd><strong>Example 2: </strong> unpaired, two-sided, two-sample t-test using
@@ -538,20 +553,19 @@
            <p>
           To compute the t-statistic:
           <source>
-TTestImpl testStatistic = new TTestImpl();
-testStatistic.t(summary1, summary2);  
+TestUtils.t(summary1, summary2);  
           </source>
            </p>
            <p>
            To compute the p-value:
            <source>
-testStatistic.tTest(sample1, sample2);
+TestUtils.tTest(sample1, sample2);
            </source>
            </p>
            <p>
            To perform a fixed significance level test with alpha = .05:
            <source>
-testStatistic.tTest(sample1, sample2, .05);    
+TestUtils.tTest(sample1, sample2, .05);    
            </source>
            </p>
            <p>
@@ -566,10 +580,9 @@
           <code>long[]</code> array of observed counts and a <code>double[]</code>
           array of expected counts, use:
           <source>
-ChiSquareTestImpl testStatistic = new ChiSquareTestImpl();
 long[] observed = {10, 9, 11};
 double[] expected = {10.1, 9.8, 10.3};
-System.out.println(testStatistic.chiSquare(expected, observed));
+System.out.println(TestUtils.chiSquare(expected, observed));
           </source>
           the value displayed will be
           <code>sum((expected[i] - observed[i])^2 / expected[i])</code>
@@ -577,7 +590,7 @@
           <dd> To get the p-value associated with the null hypothesis that
           <code>observed</code> conforms to <code>expected</code> use:
           <source>
-testStatistic.chiSquareTest(expected, observed);
+TestUtils.chiSquareTest(expected, observed);
           </source>
           </dd>    
           <dd> To test the null hypothesis that <code>observed</code> conforms to
@@ -585,7 +598,7 @@
           (equiv. <code>100 * (1-alpha)%</code> confidence) where <code>
           0 &lt; alpha &lt; 1 </code> use:
           <source>
-testStatistic.chiSquareTest(expected, observed, alpha);
+TestUtils.chiSquareTest(expected, observed, alpha);
           </source>  
           The boolean value returned will be <code>true</code> iff the null hypothesis
           can be rejected with confidence <code>1 - alpha</code>.
@@ -595,7 +608,7 @@
           chi-square test of independence</a> based on a two-dimensional (long[][])
           <code>counts</code> array viewed as a two-way table, use:
           <source>
-testStatistic.chiSquareTest(counts);
+TestUtils.chiSquareTest(counts);
           </source>
           The rows of the 2-way table are
           <code>count[0], ... , count[count.length - 1]. </code><br></br>
@@ -609,14 +622,14 @@
           the classifications represented by the counts in the columns of the input 2-way
           table are independent of the rows, use:
           <source>
-testStatistic.chiSquareTest(counts);
+ TestUtils.chiSquareTest(counts);
           </source>
           </dd>
           <dd>To perform a chi-square test of independence with <code>alpha</code>
           siginficance level (equiv. <code>100 * (1-alpha)%</code> confidence)
           where <code>0 &lt; alpha &lt; 1 </code> use:
           <source>
-testStatistic.chiSquareTest(counts, alpha);
+TestUtils.chiSquareTest(counts, alpha);
           </source>
           The boolean value returned will be <code>true</code> iff the null
           hypothesis can be rejected with confidence <code>1 - alpha</code>.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]