MATH-506 - revert r1067433 as it is incomplete; more discussion needed

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1067435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2011-02-05 12:54:25 +00:00
parent 2a8db688b1
commit 80e44be308
2 changed files with 16 additions and 7 deletions

View File

@ -36,6 +36,9 @@ import org.apache.commons.math.util.FastMath;
*/ */
public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest {
/** Distribution used to compute inference statistics. */
private ChiSquaredDistribution distribution;
/** /**
* Construct a ChiSquareTestImpl * Construct a ChiSquareTestImpl
*/ */
@ -112,7 +115,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest {
*/ */
public double chiSquareTest(double[] expected, long[] observed) public double chiSquareTest(double[] expected, long[] observed)
throws MathException { throws MathException {
ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl(expected.length - 1.0); distribution = new ChiSquaredDistributionImpl(expected.length - 1.0);
return 1.0 - distribution.cumulativeProbability( return 1.0 - distribution.cumulativeProbability(
chiSquare(expected, observed)); chiSquare(expected, observed));
} }
@ -186,7 +189,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest {
throws MathException { throws MathException {
checkArray(counts); checkArray(counts);
double df = ((double) counts.length -1) * ((double) counts[0].length - 1); double df = ((double) counts.length -1) * ((double) counts[0].length - 1);
ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl(df); distribution = new ChiSquaredDistributionImpl(df);
return 1 - distribution.cumulativeProbability(chiSquare(counts)); return 1 - distribution.cumulativeProbability(chiSquare(counts));
} }
@ -280,7 +283,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest {
*/ */
public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2)
throws MathException { throws MathException {
ChiSquaredDistributionImpl distribution = new ChiSquaredDistributionImpl((double) observed1.length - 1); distribution = new ChiSquaredDistributionImpl((double) observed1.length - 1);
return 1 - distribution.cumulativeProbability( return 1 - distribution.cumulativeProbability(
chiSquareDataSetsComparison(observed1, observed2)); chiSquareDataSetsComparison(observed1, observed2));
} }
@ -390,4 +393,14 @@ 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,10 +52,6 @@ The <action> type attribute can be add,update,fix,remove.
If the output is not quite correct, check for invisible trailing spaces! If the output is not quite correct, check for invisible trailing spaces!
--> -->
<release version="3.0" date="TBD" description="TBD"> <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"> <action dev="sebb" type="fix" issue="MATH-505">
TestUtils is thread-hostile. Remove getters and setters, and make static variables final. TestUtils is thread-hostile. Remove getters and setters, and make static variables final.
</action> </action>