Github user cestella commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/401#discussion_r93537026
--- Diff:
metron-analytics/metron-statistics/src/test/java/org/apache/metron/statistics/StellarStatisticsFunctionsTest.java
---
@@ -356,6 +357,44 @@ public void testSkewness() throws Exception {
assertEquals(stats.getSkewness(), (Double) actual, 0.1);
}
+ @Test
+ public void testStatsBin() throws Exception {
+ statsInit(windowSize);
+
statsBinRunner(StellarStatisticsFunctions.Bin.BinSplits.QUARTILE.split);
+
statsBinRunner(StellarStatisticsFunctions.Bin.BinSplits.QUARTILE.split,
"'QUARTILE'");
+
statsBinRunner(StellarStatisticsFunctions.Bin.BinSplits.QUINTILE.split,
"'QUINTILE'");
+ statsBinRunner(StellarStatisticsFunctions.Bin.BinSplits.DECILE.split,
"'DECILE'");
+ statsBinRunner(ImmutableList.of(25.0, 50.0, 75.0), "[25.0, 50.0,
75.0]");
+ }
+
+ public void statsBinRunner(List<Double> splits) throws Exception {
+ statsBinRunner(splits, null);
+ }
+
+ public void statsBinRunner(List<Double> splits, String splitsName)
throws Exception {
+ int bin = 0;
+ for(Double d : stats.getSortedValues()) {
+ StatisticsProvider provider =
(StatisticsProvider)variables.get("stats");
+ if(bin < splits.size()) {
+ double percentileOfBin = provider.getPercentile(splits.get(bin));
+ if (d > percentileOfBin) {
--- End diff --
Yes, `provider.getPercentile(x)` returns the value at percentile `x`. So,
to get the median, you'd call `provider.getPercentile(50.0)`.
If you're thinking of the inverse (give me the percentile that a value
falls at), we don't have that dude yet, but it's called the cumulative
distribution function or (`ecdf` in R parlance).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---