|
@@ -77,6 +77,8 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY));
|
|
|
assertThat(Double.isNaN(stats.getStdDeviation()), is(true));
|
|
|
assertThat(Double.isNaN(stats.getAvg()), is(true));
|
|
|
+ assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER)), is(true));
|
|
|
+ assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER)), is(true));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -99,10 +101,39 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo(0.0));
|
|
|
assertThat(stats.getVariance(), equalTo(Double.NaN));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(Double.NaN));
|
|
|
+ assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER)), is(true));
|
|
|
+ assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER)), is(true));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testSingleValuedField() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
+ SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
+ .setQuery(matchAllQuery())
|
|
|
+ .addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
|
|
+ .execute().actionGet();
|
|
|
+
|
|
|
+ assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
|
+
|
|
|
+ ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
|
|
+ assertThat(stats, notNullValue());
|
|
|
+ assertThat(stats.getName(), equalTo("stats"));
|
|
|
+ assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
|
|
|
+ assertThat(stats.getMin(), equalTo(1.0));
|
|
|
+ assertThat(stats.getMax(), equalTo(10.0));
|
|
|
+ assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
|
|
|
+ assertThat(stats.getCount(), equalTo(10l));
|
|
|
+ assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSingleValuedFieldDefaultSigma() throws Exception {
|
|
|
+
|
|
|
+ // Same as previous test, but uses a default value for sigma
|
|
|
+
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
.addAggregation(extendedStats("stats").field("value"))
|
|
@@ -119,13 +150,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
|
|
|
assertThat(stats.getCount(), equalTo(10l));
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
|
|
|
- assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
- assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ checkUpperLowerBounds(stats, 2);
|
|
|
}
|
|
|
|
|
|
public void testSingleValuedField_WithFormatter() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").format("0000.0").field("value")).execute().actionGet();
|
|
|
+ .addAggregation(extendedStats("stats").format("0000.0").field("value").sigma(sigma)).execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
|
|
|
@@ -148,6 +181,7 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getVarianceAsString(), equalTo("0008.2"));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
assertThat(stats.getStdDeviationAsString(), equalTo("0002.9"));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -199,9 +233,10 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
|
|
|
@Test
|
|
|
public void testSingleValuedField_PartiallyUnmapped() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("value"))
|
|
|
+ .addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -215,15 +250,17 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
|
|
|
assertThat(stats.getCount(), equalTo(10l));
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
|
|
|
- assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
- assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testSingleValuedField_WithValueScript() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("value").script("_value + 1"))
|
|
|
+ .addAggregation(extendedStats("stats").field("value").script("_value + 1").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -237,15 +274,17 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
|
|
|
assertThat(stats.getCount(), equalTo(10l));
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
|
|
|
- assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
- assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("value").script("_value + inc").param("inc", 1))
|
|
|
+ .addAggregation(extendedStats("stats").field("value").script("_value + inc").param("inc", 1).sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -259,15 +298,17 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
|
|
|
assertThat(stats.getCount(), equalTo(10l));
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
|
|
|
- assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
- assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testMultiValuedField() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("values"))
|
|
|
+ .addAggregation(extendedStats("stats").field("values").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -281,15 +322,17 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12));
|
|
|
assertThat(stats.getCount(), equalTo(20l));
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144));
|
|
|
- assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
- assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
+ assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
|
|
+ assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testMultiValuedField_WithValueScript() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("values").script("_value - 1"))
|
|
|
+ .addAggregation(extendedStats("stats").field("values").script("_value - 1").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -305,13 +348,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").field("values").script("_value - dec").param("dec", 1))
|
|
|
+ .addAggregation(extendedStats("stats").field("values").script("_value - dec").param("dec", 1).sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -327,13 +372,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_SingleValued() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("doc['value'].value"))
|
|
|
+ .addAggregation(extendedStats("stats").script("doc['value'].value").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -349,13 +396,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_SingleValued_WithParams() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1))
|
|
|
+ .addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1).sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -371,13 +420,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_ExplicitSingleValued_WithParams() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1))
|
|
|
+ .addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1).sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -393,13 +444,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_MultiValued() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("doc['values'].values"))
|
|
|
+ .addAggregation(extendedStats("stats").script("doc['values'].values").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -415,13 +468,15 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_ExplicitMultiValued() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("doc['values'].values"))
|
|
|
+ .addAggregation(extendedStats("stats").script("doc['values'].values").sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertShardExecutionState(searchResponse, 0);
|
|
@@ -438,14 +493,16 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testScript_MultiValued_WithParams() throws Exception {
|
|
|
+ double sigma = randomDouble() * randomIntBetween(1, 10);
|
|
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
|
.setQuery(matchAllQuery())
|
|
|
- .addAggregation(extendedStats("stats").script("[ doc['value'].value, doc['value'].value - dec ]").param("dec", 1))
|
|
|
+ .addAggregation(extendedStats("stats").script("[ doc['value'].value, doc['value'].value - dec ]").param("dec", 1).sigma(sigma))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
|
@@ -461,6 +518,7 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+0+1+4+9+16+25+36+49+64+81));
|
|
|
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9)));
|
|
|
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9)));
|
|
|
+ checkUpperLowerBounds(stats, sigma);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -474,4 +532,10 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|
|
}
|
|
|
assertThat("Not all shards are initialized", response.getSuccessfulShards(), equalTo(response.getTotalShards()));
|
|
|
}
|
|
|
+
|
|
|
+ private void checkUpperLowerBounds(ExtendedStats stats, double sigma) {
|
|
|
+ assertThat(stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER), equalTo(stats.getAvg() + (stats.getStdDeviation() * sigma)));
|
|
|
+ assertThat(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), equalTo(stats.getAvg() - (stats.getStdDeviation() * sigma)));
|
|
|
+ }
|
|
|
+
|
|
|
}
|