20 package com.griddynamics.jagger.engine.e1.collector;
22 import com.google.common.collect.Lists;
24 import java.util.List;
26 import static com.griddynamics.jagger.util.StandardMetricsNamesUtil.STANDARD_DEVIATION_AGGREGATOR_ID;
37 return new StdDevMetricAggregator();
40 private static class StdDevMetricAggregator
implements MetricAggregator<Number> {
42 List<Number> points = null;
45 private double getMean() {
48 for (Number d : points) {
49 sum += d.doubleValue();
51 return sum / points.size();
56 public void append(Number calculated) {
58 points = Lists.newLinkedList();
60 points.add(calculated);
64 public Number getAggregated() {
68 double mean = getMean();
71 for (Number d : points) {
72 sum += (d.doubleValue() - mean) * (d.doubleValue() - mean);
75 return Math.sqrt(sum / points.size());
84 public String getName() {
85 return STANDARD_DEVIATION_AGGREGATOR_ID;
89 public String toString() {
90 return "StdDevMetricAggregator{" +