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
This commit is contained in:
Sebastian Bazley 2011-02-05 12:46:36 +00:00
parent cc53a6aa67
commit 2a8db688b1
2 changed files with 7 additions and 16 deletions

View File

@ -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;
}
}

View File

@ -52,6 +52,10 @@ The <action> type attribute can be add,update,fix,remove.
If the output is not quite correct, check for invisible trailing spaces!
-->
<release version="3.0" date="TBD" description="TBD">
<action dev="sebb" type="fix" issue="MATH-506">
The static field ChiSquareTestImpl.distribution serves no purpose.
Removed setter and static field, and made other instances local variables.
</action>
<action dev="sebb" type="fix" issue="MATH-505">
TestUtils is thread-hostile. Remove getters and setters, and make static variables final.
</action>