From 2a8db688b1031ede4feab1351714144a6ec5e9ff Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Sat, 5 Feb 2011 12:46:36 +0000 Subject: [PATCH] MATH-506 The static field ChiSquareTestImpl.distribution serves no purpose. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1067433 13f79535-47bb-0310-9956-ffa450edef68 --- .../stat/inference/ChiSquareTestImpl.java | 19 +++---------------- src/site/xdoc/changes.xml | 4 ++++ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java b/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java index 407b082ea..07b9cd883 100644 --- a/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java +++ b/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java @@ -36,9 +36,6 @@ import org.apache.commons.math.util.FastMath; */ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { - /** Distribution used to compute inference statistics. */ - private ChiSquaredDistribution distribution; - /** * Construct a ChiSquareTestImpl */ @@ -115,7 +112,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { */ public double chiSquareTest(double[] expected, long[] observed) throws MathException { - distribution = new ChiSquaredDistributionImpl(expected.length - 1.0); + ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl(expected.length - 1.0); return 1.0 - distribution.cumulativeProbability( chiSquare(expected, observed)); } @@ -189,7 +186,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { throws MathException { checkArray(counts); double df = ((double) counts.length -1) * ((double) counts[0].length - 1); - distribution = new ChiSquaredDistributionImpl(df); + ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl(df); return 1 - distribution.cumulativeProbability(chiSquare(counts)); } @@ -283,7 +280,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { */ public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws MathException { - distribution = new ChiSquaredDistributionImpl((double) observed1.length - 1); + ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl((double) observed1.length - 1); return 1 - distribution.cumulativeProbability( chiSquareDataSetsComparison(observed1, observed2)); } @@ -393,14 +390,4 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { } } - /** - * Modify the distribution used to compute inference statistics. - * - * @param value - * the new distribution - * @since 1.2 - */ - public void setDistribution(ChiSquaredDistribution value) { - distribution = value; - } } diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index 8f7af9139..ecab662ef 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -52,6 +52,10 @@ The type attribute can be add,update,fix,remove. If the output is not quite correct, check for invisible trailing spaces! --> + + The static field ChiSquareTestImpl.distribution serves no purpose. + Removed setter and static field, and made other instances local variables. + TestUtils is thread-hostile. Remove getters and setters, and make static variables final.