[
https://issues.apache.org/jira/browse/MATH-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17119492#comment-17119492
]
Steffen Herbold edited comment on MATH-1535 at 5/29/20, 11:05 AM:
------------------------------------------------------------------
Some more investigation: increasing the number of loops does indeed increase
the risk of modifying the results, because the sample order may be broken. I
ran the following after increasing the number of loops in fixTies to 10000.
{code:java}
@Test
public void testMath1535() throws Exception {
KolmogorovSmirnovTest ksTest = new KolmogorovSmirnovTest();
double[] sampleX = new double[] {0.8767630865438496, 0.9998809418147052,
0.9999999715463531, 0.9999985849345421, 0.973584315883326, 0.9999999875782982,
0.999999999999994, 0.9999999999908233, 1.0, 0.9999999890925574,
0.9999998345734327, 0.9999999350772448, 0.999999999999426, 0.9999147040688201,
0.9999999999999922, 1.0, 1.0, 0.9919050954798272, 0.8649014770687263,
0.9990869497973084, 0.9993222540990464, 0.999999999998189, 0.9999999999999365,
0.9790934801762917, 0.9999578695006303, 0.9999999999999998, 0.999999999996166,
0.9999999999995546, 0.9999999999908036, 0.99999999999744, 0.9999998802655555,
0.9079334221214075, 0.9794398308007372, 0.9999044231134367, 0.9999999999999813,
0.9999957841707683, 0.9277678892094009, 0.999948269893843, 0.9999999886132888,
0.9999998909699096, 0.9999099536620326, 0.9999999962217623, 0.9138936987350447,
0.9999999999779976, 0.999999999998822, 0.999979247207911, 0.9926904388316407,
1.0, 0.9999999999998814, 1.0, 0.9892505696426215, 0.9999996514123723,
0.9999999999999429, 0.9999999995399116, 0.999999999948221, 0.7358264887843119,
0.9999999994098534, 1.0, 0.9999986456748472, 1.0, 0.9999999999921501,
0.9999999999999996, 0.9999999999999944, 0.9473070068606853, 0.9993714060209042,
0.9999999409098718, 0.9999999592791519, 0.9999999999999805};
double[] sampleY = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
ksTest.kolmogorovSmirnovTest(sampleX, sampleY); // passes
checkFixTies(sampleX, sampleY); // fails
}{code}
was (Author: sherbold):
Some more investigation: increasing the number of loops does indeed increase
the risk of modifying the results, because the sample order may be broken.
{code:java}
@Test
public void testMath1535() throws Exception {
KolmogorovSmirnovTest ksTest = new KolmogorovSmirnovTest();
double[] sampleX = new double[] {0.8767630865438496, 0.9998809418147052,
0.9999999715463531, 0.9999985849345421, 0.973584315883326, 0.9999999875782982,
0.999999999999994, 0.9999999999908233, 1.0, 0.9999999890925574,
0.9999998345734327, 0.9999999350772448, 0.999999999999426, 0.9999147040688201,
0.9999999999999922, 1.0, 1.0, 0.9919050954798272, 0.8649014770687263,
0.9990869497973084, 0.9993222540990464, 0.999999999998189, 0.9999999999999365,
0.9790934801762917, 0.9999578695006303, 0.9999999999999998, 0.999999999996166,
0.9999999999995546, 0.9999999999908036, 0.99999999999744, 0.9999998802655555,
0.9079334221214075, 0.9794398308007372, 0.9999044231134367, 0.9999999999999813,
0.9999957841707683, 0.9277678892094009, 0.999948269893843, 0.9999999886132888,
0.9999998909699096, 0.9999099536620326, 0.9999999962217623, 0.9138936987350447,
0.9999999999779976, 0.999999999998822, 0.999979247207911, 0.9926904388316407,
1.0, 0.9999999999998814, 1.0, 0.9892505696426215, 0.9999996514123723,
0.9999999999999429, 0.9999999995399116, 0.999999999948221, 0.7358264887843119,
0.9999999994098534, 1.0, 0.9999986456748472, 1.0, 0.9999999999921501,
0.9999999999999996, 0.9999999999999944, 0.9473070068606853, 0.9993714060209042,
0.9999999409098718, 0.9999999592791519, 0.9999999999999805};
double[] sampleY = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
ksTest.kolmogorovSmirnovTest(sampleX, sampleY); // passes
checkFixTies(sampleX, sampleY); // fails
}{code}
> MathInternalError in KolmogorovSmirnovTest in case of many ties
> ---------------------------------------------------------------
>
> Key: MATH-1535
> URL: https://issues.apache.org/jira/browse/MATH-1535
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.6.1
> Environment: commons-math 3.6.1, oracle jdk11 for windows
> Reporter: Steffen Herbold
> Priority: Major
>
> I encounter a math internal error with some very ugly data that has lots of
> ties. The code below triggers the exception. I could try to build in a
> detection in my code that identifies this strange case where the generated
> data has many ties, to avoid this. But I guess the MathInternalError in
> commons-math should still be avoided.
>
> {code:java}
> // works
> double[] sample1 = new double[] {0.8767630865438496, 0.9998809418147052,
> 0.9999999715463531, 0.9999985849345421};
> double[] sample2 = new double[] {1.0, 1.0, 1.0, 1.0};
> ksTest.kolmogorovSmirnovTest(sample1, sample2);
> // fails with illegal state
> double[] sample3 = new double[] {0.8767630865438496, 0.9998809418147052,
> 0.9999999715463531, 0.9999985849345421, 0.973584315883326,
> 0.9999999875782982, 0.999999999999994, 0.9999999999908233, 1.0,
> 0.9999999890925574, 0.9999998345734327, 0.9999999350772448,
> 0.999999999999426, 0.9999147040688201, 0.9999999999999922, 1.0, 1.0,
> 0.9919050954798272, 0.8649014770687263, 0.9990869497973084,
> 0.9993222540990464, 0.999999999998189, 0.9999999999999365,
> 0.9790934801762917, 0.9999578695006303, 0.9999999999999998,
> 0.999999999996166, 0.9999999999995546, 0.9999999999908036, 0.99999999999744,
> 0.9999998802655555, 0.9079334221214075, 0.9794398308007372,
> 0.9999044231134367, 0.9999999999999813, 0.9999957841707683,
> 0.9277678892094009, 0.999948269893843, 0.9999999886132888,
> 0.9999998909699096, 0.9999099536620326, 0.9999999962217623,
> 0.9138936987350447, 0.9999999999779976, 0.999999999998822, 0.999979247207911,
> 0.9926904388316407, 1.0, 0.9999999999998814, 1.0, 0.9892505696426215,
> 0.9999996514123723, 0.9999999999999429, 0.9999999995399116,
> 0.999999999948221, 0.7358264887843119, 0.9999999994098534, 1.0,
> 0.9999986456748472, 1.0, 0.9999999999921501, 0.9999999999999996,
> 0.9999999999999944, 0.9473070068606853, 0.9993714060209042,
> 0.9999999409098718, 0.9999999592791519, 0.9999999999999805};
> double[] sample4 = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
> 1.0};
> ksTest.kolmogorovSmirnovTest(sample3, sample4);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)