提交 5156a1b3 编写于 作者: C chengxiang li 提交者: Chiwan Park

[FLINK-2564] [core] Improve stability of RandomSamplerTest

  - Expand the verification boundary for random sampler test
  - Increase the number of times we sample

This closes #1047
上级 cf88407a
......@@ -239,14 +239,14 @@ public class RandomSamplerTest {
sampler = new BernoulliSampler<Double>(fraction);
}
// take 5 times sample, and take the average result size for next step comparison.
// take 20 times sample, and take the average result size for next step comparison.
int totalSampledSize = 0;
double sampleCount = 5;
double sampleCount = 20;
for (int i = 0; i < sampleCount; i++) {
totalSampledSize += getSize(sampler.sample(source.iterator()));
}
double resultFraction = totalSampledSize / ((double) SOURCE_SIZE * sampleCount);
assertTrue(String.format("expected fraction: %f, result fraction: %f", fraction, resultFraction), Math.abs((resultFraction - fraction) / fraction) < 0.1);
assertTrue(String.format("expected fraction: %f, result fraction: %f", fraction, resultFraction), Math.abs((resultFraction - fraction) / fraction) < 0.2);
}
/*
......@@ -440,13 +440,13 @@ public class RandomSamplerTest {
}
/*
* Calculate the D value of K-S test for p-value 0.05, m and n are the sample size
* Calculate the D value of K-S test for p-value 0.01, m and n are the sample size
*/
private double getDValue(int m, int n) {
Preconditions.checkArgument(m > 0, "input sample size should be positive.");
Preconditions.checkArgument(n > 0, "input sample size should be positive.");
double first = (double) m;
double second = (double) n;
return 1.36 * Math.sqrt((first + second) / (first * second));
return 1.63 * Math.sqrt((first + second) / (first * second));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册