You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2017/05/09 03:07:36 UTC
[1/2] [math] MATH-1381: changes.xml entry
Repository: commons-math
Updated Branches:
refs/heads/master 53ec46ba2 -> f5b5a8b0b
MATH-1381: changes.xml entry
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/f5b5a8b0
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/f5b5a8b0
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/f5b5a8b0
Branch: refs/heads/master
Commit: f5b5a8b0bcb9c2e5ac12d757892854a890c3ab85
Parents: 9df5e94
Author: Bruno P. Kinoshita <br...@yahoo.com.br>
Authored: Tue May 9 15:05:25 2017 +1200
Committer: Bruno P. Kinoshita <br...@yahoo.com.br>
Committed: Tue May 9 15:06:52 2017 +1200
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/f5b5a8b0/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d8dbd44..1b75585 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@ If the output is not quite correct, check for invisible trailing spaces!
</release>
<release version="4.0" date="XXXX-XX-XX" description="">
+ <action dev="kinow" type="fix" issue="MATH-1381" due-to="Kexin Xie">
+ BinomialTest P-value > 1
+ </action>
<action dev="erans" type="fix" issue="MATH-1382" due-to="Stefan Bunk">
"MultivariateNormalDistribution": performance improvement (by
removing unnecessary copying).
[2/2] [math] fix a bug that sometimes Binomial test return
probability greater than 1
Posted by ki...@apache.org.
fix a bug that sometimes Binomial test return probability greater than 1
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9df5e941
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9df5e941
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9df5e941
Branch: refs/heads/master
Commit: 9df5e9419d83c11b4a2c3421c5ff7ea1f544366b
Parents: 53ec46b
Author: Kexin Xie <ke...@salesforce.com>
Authored: Sun May 7 09:47:14 2017 -0700
Committer: Bruno P. Kinoshita <br...@yahoo.com.br>
Committed: Tue May 9 15:06:52 2017 +1200
----------------------------------------------------------------------
.../math4/stat/inference/BinomialTest.java | 6 ++-
.../math4/stat/inference/BinomialTestTest.java | 48 ++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9df5e941/src/main/java/org/apache/commons/math4/stat/inference/BinomialTest.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/inference/BinomialTest.java b/src/main/java/org/apache/commons/math4/stat/inference/BinomialTest.java
index 2846c68..4a94130 100644
--- a/src/main/java/org/apache/commons/math4/stat/inference/BinomialTest.java
+++ b/src/main/java/org/apache/commons/math4/stat/inference/BinomialTest.java
@@ -135,7 +135,11 @@ public class BinomialTest {
double pHigh = distribution.probability(criticalValueHigh);
if (pLow == pHigh) {
- pTotal += 2 * pLow;
+ if (criticalValueLow == criticalValueHigh) {
+ pTotal += pLow;
+ } else {
+ pTotal += 2 * pLow;
+ }
criticalValueLow++;
criticalValueHigh--;
} else if (pLow < pHigh) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9df5e941/src/test/java/org/apache/commons/math4/stat/inference/BinomialTestTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/inference/BinomialTestTest.java b/src/test/java/org/apache/commons/math4/stat/inference/BinomialTestTest.java
index 365f21d..55e1730 100644
--- a/src/test/java/org/apache/commons/math4/stat/inference/BinomialTestTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/inference/BinomialTestTest.java
@@ -42,6 +42,54 @@ public class BinomialTestTest {
trials, successes, probability, AlternativeHypothesis.GREATER_THAN), 1E-4);
Assert.assertEquals(0.982, testStatistic.binomialTest(
trials, successes, probability, AlternativeHypothesis.LESS_THAN), 1E-4);
+
+ // for special boundary conditions
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 3, 1, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 3, 0.9, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 3, 0.8, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.559, testStatistic.binomialTest(
+ 3, 3, 0.7, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.28, testStatistic.binomialTest(
+ 3, 3, 0.6, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.25, testStatistic.binomialTest(
+ 3, 3, 0.5, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.064, testStatistic.binomialTest(
+ 3, 3, 0.4, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.027, testStatistic.binomialTest(
+ 3, 3, 0.3, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.008, testStatistic.binomialTest(
+ 3, 3, 0.2, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.001, testStatistic.binomialTest(
+ 3, 3, 0.1, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0, testStatistic.binomialTest(
+ 3, 3, 0.0, AlternativeHypothesis.TWO_SIDED), 1E-4);
+
+ Assert.assertEquals(0, testStatistic.binomialTest(
+ 3, 0, 1, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.001, testStatistic.binomialTest(
+ 3, 0, 0.9, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.008, testStatistic.binomialTest(
+ 3, 0, 0.8, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.027, testStatistic.binomialTest(
+ 3, 0, 0.7, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.064, testStatistic.binomialTest(
+ 3, 0, 0.6, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.25, testStatistic.binomialTest(
+ 3, 0, 0.5, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.28, testStatistic.binomialTest(
+ 3, 0, 0.4, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(0.559, testStatistic.binomialTest(
+ 3, 0, 0.3, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 0, 0.2, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 0, 0.1, AlternativeHypothesis.TWO_SIDED), 1E-4);
+ Assert.assertEquals(1, testStatistic.binomialTest(
+ 3, 0, 0.0, AlternativeHypothesis.TWO_SIDED), 1E-4);
+
}
@Test