[
https://issues.apache.org/jira/browse/STATISTICS-104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alex Herbert updated STATISTICS-104:
------------------------------------
Description:
The FisherExactTest computes the two-sided probability using the probability
that a random table has probability equal to or less than the input table. Both
the computation for the input table, and the computation for other tables are
inexact. Their p-values can vary by a few ULP. In this case the test may not
identify random tables that have an equal probability to the input table. Use
of {{p(other) <= p(input)}} is too strict and tables with the same probability
can be missed.
FisherExactTest:
{noformat}
TWO_SIDED
{{0, 2}, {2, 3}} : 0.5238095238095237 -> 1.0
{{2, 8}, {13, 7}} : 0.027686156921539203 -> 502/10005 =
0.050174912543728{noformat}
This also affects the UnconditionedExactTest and the BinomialTest where
searches for p-values {{<=}} target are used.
UnconditionedExactTest:
{noformat}
TWO_SIDED
{{0,2},{2,3}} 0.4375 -> 1.0
{{1,0},{10,11}} 0.3340 -> 1
{{2,8},{13,7}} 0.0174 -> 0.0234
{{0,7},{4,4}} 0.0376 -> 0.0510
{{3,1},{4,13}} 0.0660 -> 0.0475
LESS_THAN
{{3,4},{4,3}} 0.2876 -> 0.3953
{{3,8},{5,2}} 0.0470 -> 0.0550{noformat}
BinomialTest
{noformat}
TWO_SIDED
(3, 2) 0.625 -> 1
(21, 10) 0.832 -> 1
(13, 3) 0.0574 -> 0.0923
(19, 5) 0.0414 -> 0.0636{noformat}
The suggested fix is to add a tolerance for equality. This can raise the
threshold for {{<=}} to a higher value:
{noformat}
p = p + p * eps{noformat}
Where eps is a small relative epsilon. This is effectively zero in the current
code. It could be configured using a setter method:
{code:java}
FisherExactTest.withDefaults().withRelativeTolerance(1e-15)
{code}
This bug was identified and the error cases provided by Eran Shaham.
was:
The FisherExactTest computes the two-sided probability using the probability
that a random table has probability equal to or less than the input table. Both
the computation for the input table, and the computation for other tables are
inexact. Their p-values can vary by a few ULP. In this case the test may not
identify random tables that have an equal probability to the input table. Use
of {{p(other) <= p(input)}} is too strict and tables with the same probability
can be missed.
FisherExactTest:
{noformat}
TWO_SIDED
{{0, 2}, {2, 3}} : 0.5238095238095237 -> 1.0
{{2, 8}, {13, 7}} : 0.027686156921539203 -> 502/10005 =
0.050174912543728{noformat}
This also affects the UnconditionedExactTest and the BinomialTest where
searches for p-values {{<=}} target are used.
UnconditionedExactTest:
{noformat}
TWO_SIDED
{{0,2},{2,3}} 0.4375 -> 1.0
{{1,0},{10,11}} 0.3340 -> 1
{{2,8},{13,7}} 0.0174 -> 0.0234
{{0,7},{4,4}} 0.0376 -> 0.0510
{{3,1},{4,13}} 0.0660 -> 0.0475
LESS_THAN
{{3,4},{4,3}} 0.2876 -> 0.3953
{{3,8},{5,2}} 0.0470 -> 0.0550{noformat}
BinomialTest
{noformat}
TWO_SIDED
(3, 2) 0.625 -> 1
(21, 10) 0.832 -> 1
(13, 3) 0.0574 -> 0.0923
(19, 5) 0.0414 -> 0.0636{noformat}
The suggested fix is to add a tolerance for equality. This can raise the
threshold for {{<=}} to a higher value:
{noformat}
p = p + p * eps{noformat}
Where eps is a small relative epsilon. This is effectively zero in the current
code. It could be configured using a setter method:
{code:java}
FisherExactTest.withDefaults().withRelativeTolerance(1e-15)
{code}
This bug was identified and the error cases provided by Eran Shaham.
> Inference p-values are incorrect when less-than-or-equal probability
> comparisons have rounding errors in the p-values being compared
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: STATISTICS-104
> URL: https://issues.apache.org/jira/browse/STATISTICS-104
> Project: Commons Statistics
> Issue Type: Bug
> Components: inference
> Affects Versions: 1.3
> Reporter: Alex Herbert
> Priority: Minor
>
> The FisherExactTest computes the two-sided probability using the probability
> that a random table has probability equal to or less than the input table.
> Both the computation for the input table, and the computation for other
> tables are inexact. Their p-values can vary by a few ULP. In this case the
> test may not identify random tables that have an equal probability to the
> input table. Use of {{p(other) <= p(input)}} is too strict and tables with
> the same probability can be missed.
> FisherExactTest:
> {noformat}
> TWO_SIDED
> {{0, 2}, {2, 3}} : 0.5238095238095237 -> 1.0
> {{2, 8}, {13, 7}} : 0.027686156921539203 -> 502/10005 =
> 0.050174912543728{noformat}
> This also affects the UnconditionedExactTest and the BinomialTest where
> searches for p-values {{<=}} target are used.
> UnconditionedExactTest:
> {noformat}
> TWO_SIDED
> {{0,2},{2,3}} 0.4375 -> 1.0
> {{1,0},{10,11}} 0.3340 -> 1
> {{2,8},{13,7}} 0.0174 -> 0.0234
> {{0,7},{4,4}} 0.0376 -> 0.0510
> {{3,1},{4,13}} 0.0660 -> 0.0475
> LESS_THAN
> {{3,4},{4,3}} 0.2876 -> 0.3953
> {{3,8},{5,2}} 0.0470 -> 0.0550{noformat}
> BinomialTest
> {noformat}
> TWO_SIDED
> (3, 2) 0.625 -> 1
> (21, 10) 0.832 -> 1
> (13, 3) 0.0574 -> 0.0923
> (19, 5) 0.0414 -> 0.0636{noformat}
> The suggested fix is to add a tolerance for equality. This can raise the
> threshold for {{<=}} to a higher value:
> {noformat}
> p = p + p * eps{noformat}
> Where eps is a small relative epsilon. This is effectively zero in the
> current code. It could be configured using a setter method:
> {code:java}
> FisherExactTest.withDefaults().withRelativeTolerance(1e-15)
> {code}
> This bug was identified and the error cases provided by Eran Shaham.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)