public Object processAdd(double value) {
            // See here for the algorithm: http://www.johndcook.com/blog/standard_deviation/
            count++;
            if (count == 0) {
                return null;
            } else if (count == 1) {
                sum = mean = value;
                stdDeviation = 0.0;
                return 0.0;
            } else {
                double oldMean = mean;
                sum += value;
                mean = sum / count;
                stdDeviation += (value - oldMean) * (value - mean);
                return Math.sqrt(stdDeviation / count);
            }
        }
Standard deviation abstrct aggregator for Double values
modules/siddhi-core/src/main/java/io/siddhi/core/query/selector/attribute/aggregator/StdDevAttributeAggregatorExecutor.java