Example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getVariance

List of usage examples for org.apache.commons.math.stat.descriptive SummaryStatistics getVariance

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getVariance.

Prototype

public double getVariance() 

Source Link

Document

Returns the variance of the values that have been added.

Usage

From source file:boa.aggregators.VarianceAggregator.java

/** {@inheritDoc} */
@Override//from   w  w w.j  a  v a  2s  .c  om
public void finish() throws IOException, InterruptedException {
    if (this.isCombining()) {
        String s = "";
        for (final Long key : map.keySet())
            s += key + ":" + map.get(key) + ";";
        this.collect(s, null);
        return;
    }

    final SummaryStatistics summaryStatistics = new SummaryStatistics();

    for (final Long key : map.keySet()) {
        final long count = map.get(key);
        for (long i = 0; i < count; i++)
            summaryStatistics.addValue(key);
    }

    this.collect(summaryStatistics.getVariance());
}

From source file:gsn.tests.performance.Queries.java

private String printStats(SummaryStatistics stats, String unit) {
    return new StringBuilder().append("sum:").append(format(stats.getSum())).append(", min:")
            .append(format(stats.getMin())).append(", max:").append(format(stats.getMax())).append(", mean:")
            .append(format(stats.getMean())).append(", var:").append(format(stats.getVariance())).append(" [")
            .append(unit).append("]").toString();
}

From source file:it.univpm.deit.semedia.musicuri.utils.experimental.LambdaCalculator.java

public static void mergeStatistics(ArrayList allStats) {
    PerformanceStatistic tempStat;//from w w  w.j  a  va 2s.  com

    int truePositives = 0;
    int falsePositives = 0;
    int trueNegatives = 0;
    int falseNegatives = 0;

    SummaryStatistics TPBestMatchSummary = SummaryStatistics.newInstance();
    SummaryStatistics TPSecondBestSummary = SummaryStatistics.newInstance();

    SummaryStatistics FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics BothTP_FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics TNSummary = SummaryStatistics.newInstance();
    SummaryStatistics FNSummary = SummaryStatistics.newInstance();

    SummaryStatistics pruningSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics matchingSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics totalSpeedSummary = SummaryStatistics.newInstance();

    for (int i = 0; i < allStats.size(); i++) {
        tempStat = (PerformanceStatistic) allStats.get(i);

        if (tempStat.isTruePositive())
            truePositives++;
        if (tempStat.isFalsePositive())
            falsePositives++;
        if (tempStat.isTrueNegative())
            trueNegatives++;
        if (tempStat.isFalseNegative())
            falseNegatives++;

        // accurate results only
        //if (tempStat.isTruePositive() || tempStat.isTrueNegative())

        pruningSpeedSummary.addValue(tempStat.getPruningTime());
        matchingSpeedSummary.addValue(tempStat.getMatchingTime());
        totalSpeedSummary.addValue(tempStat.getPruningTime() + tempStat.getMatchingTime());

        if (tempStat.isTruePositive()) {
            TPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
            TPSecondBestSummary.addValue(tempStat.getSecondBestMatchDistance());
        }

        if (tempStat.isFalsePositive()) {
            FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        }

        BothTP_FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());

    }

    System.out.println("---------------------------------------------------------");

    System.out.println("\nTrue Positives      : " + truePositives + "/" + allStats.size());
    System.out.println("False Positives     : " + falsePositives + "/" + allStats.size());
    System.out.println("True Negatives      : " + trueNegatives + "/" + allStats.size());
    System.out.println("False Negatives     : " + falseNegatives + "/" + allStats.size());

    System.out.println("\nTrue Positive Best Match Statistics");
    System.out.println("Distance Min        : " + TPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + TPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + TPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + TPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + TPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (TPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nTrue Positive Second Best Statistics");
    System.out.println("Distance Min        : " + TPSecondBestSummary.getMin());
    System.out.println("Distance Max        : " + TPSecondBestSummary.getMax());
    System.out.println("Distance Mean       : " + TPSecondBestSummary.getMean());
    System.out.println("Confidence Mean     : " + (100 - (100 * (TPSecondBestSummary.getMean()))) + " %");

    System.out.println("\nFalse Positive Best Match Statistics");
    System.out.println("Distance Min        : " + FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + FPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nBest Match Statistics (Regardless being False or True Positive) ");
    System.out.println("Distance Min        : " + BothTP_FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + BothTP_FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + BothTP_FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + BothTP_FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + BothTP_FPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (BothTP_FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n\nPruning Speed Statistics");
    System.out.println("Speed Min           : " + (pruningSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (pruningSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (pruningSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nMatching Speed Statistics");
    System.out.println("Speed Min           : " + (matchingSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (matchingSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (matchingSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nOverall Speed Statistics");
    System.out.println("Speed Min           : " + (totalSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (totalSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (totalSpeedSummary.getMean() / 1000) + " sec");

}

From source file:it.univpm.deit.semedia.musicuri.core.MusicURISearch.java

/**
 * Accumulates and prints performance statistics regarding speed and accuracy for a certain batch of tests. 
 * @param allStats an ArrayList containing PerformanceStatistic objects
 *//*w w  w  . j ava 2s.c o  m*/
public void mergeStatistics(ArrayList allStats) {
    PerformanceStatistic tempStat;

    int truePositives = 0;
    int falsePositives = 0;
    int trueNegatives = 0;
    int falseNegatives = 0;

    SummaryStatistics TPBestMatchSummary = SummaryStatistics.newInstance();
    SummaryStatistics SecondBestSummary = SummaryStatistics.newInstance();
    SummaryStatistics WorstMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics BothTP_FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics TNSummary = SummaryStatistics.newInstance();
    SummaryStatistics FNSummary = SummaryStatistics.newInstance();

    SummaryStatistics pruningSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics matchingSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics totalSpeedSummary = SummaryStatistics.newInstance();

    for (int i = 0; i < allStats.size(); i++) {
        tempStat = (PerformanceStatistic) allStats.get(i);

        if (tempStat.isTruePositive())
            truePositives++;
        if (tempStat.isFalsePositive())
            falsePositives++;
        if (tempStat.isTrueNegative())
            trueNegatives++;
        if (tempStat.isFalseNegative())
            falseNegatives++;

        // accurate results only
        //if (tempStat.isTruePositive() || tempStat.isTrueNegative())

        pruningSpeedSummary.addValue(tempStat.getPruningTime());
        matchingSpeedSummary.addValue(tempStat.getMatchingTime());
        totalSpeedSummary.addValue(tempStat.getPruningTime() + tempStat.getMatchingTime());

        if (tempStat.isTruePositive()) {
            TPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
            SecondBestSummary.addValue(tempStat.getSecondBestMatchDistance());
        }

        if (tempStat.isFalsePositive()) {
            FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        }

        BothTP_FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        WorstMatchSummary.addValue(tempStat.getWorstMatchDistance());
    }

    System.out.println("---------------------------------------------------------");

    System.out.println("\nTrue Positives      : " + truePositives + "/" + allStats.size());
    System.out.println("False Positives     : " + falsePositives + "/" + allStats.size());
    System.out.println("True Negatives      : " + trueNegatives + "/" + allStats.size());
    System.out.println("False Negatives     : " + falseNegatives + "/" + allStats.size());

    System.out.println("\nTrue Positive Best Match Statistics");
    System.out.println("Distance Min        : " + TPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + TPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + TPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + TPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + TPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (TPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n2nd Match Statistics");
    System.out.println("Distance Min        : " + SecondBestSummary.getMin());
    System.out.println("Distance Max        : " + SecondBestSummary.getMax());
    System.out.println("Distance Mean       : " + SecondBestSummary.getMean());
    System.out.println("Score Mean          : " + (100 - (100 * (SecondBestSummary.getMean()))) + " %");

    System.out.println("\nNth Match Statistics");
    System.out.println("Distance Min        : " + WorstMatchSummary.getMin());
    System.out.println("Distance Max        : " + WorstMatchSummary.getMax());
    System.out.println("Distance Mean       : " + WorstMatchSummary.getMean());
    System.out.println("Score Mean          : " + (100 - (100 * (WorstMatchSummary.getMean()))) + " %");

    System.out.println("\nFalse Positive Best Match Statistics");
    System.out.println("Distance Min        : " + FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + FPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nBest Match Statistics (Regardless being False or True Positive) ");
    System.out.println("Distance Min        : " + BothTP_FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + BothTP_FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + BothTP_FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + BothTP_FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + BothTP_FPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (BothTP_FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n\nPruning Speed Statistics");
    System.out.println("Speed Min           : " + (pruningSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (pruningSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (pruningSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nMatching Speed Statistics");
    System.out.println("Speed Min           : " + (matchingSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (matchingSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (matchingSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nOverall Speed Statistics");
    System.out.println("Speed Min           : " + (totalSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (totalSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (totalSpeedSummary.getMean() / 1000) + " sec");

}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Add the calculated process time-metrics to the simulation model
 * //  w w w . ja  va2s  .  com
 * @param logTraces
 *            ArrayList the process instances
 */
private void fillProcessHighLevelPN(ArrayList logTraces) {
    try {
        replayResult.calculateMetrics(logTraces, advancedSettings[0]);
        // add the arrival rate to the HighLevelProcess model
        double arrivalRate = (double) replayResult.getArrivalRate() * (double) timeDivider;
        SummaryStatistics arrivalStats = replayResult.getArrivalStats();

        HLGeneralDistribution dist = new HLGeneralDistribution(arrivalStats.getMean() / (double) timeDivider,
                arrivalStats.getMean() / (double) timeDivider,
                arrivalStats.getVariance() / (double) timeDivider, arrivalStats.getMin() / (double) timeDivider,
                arrivalStats.getMax() / (double) timeDivider, arrivalRate,
                HLDistribution.DistributionEnum.EXPONENTIAL_DISTRIBUTION);

        highLevelPN.getHLProcess().getGlobalInfo().setCaseGenerationScheme(dist);
        // set the time unit of the HighLevelProcess model
        // different time strings: "milliseconds", "seconds", "minutes",
        // "hours", "days", "weeks", "months", "years"
        if (timeSort.equals("milliseconds")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MILLISECONDS);
        } else if (timeSort.equals("seconds")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.SECONDS);
        } else if (timeSort.equals("minutes")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MINUTES);
        } else if (timeSort.equals("hours")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.HOURS);
        } else if (timeSort.equals("days")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.DAYS);
        } else if (timeSort.equals("weeks")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.WEEKS);
        } else if (timeSort.equals("months")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MONTHS);
        } else if (timeSort.equals("years")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.YEARS);
        } else {
            // use default value
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.HOURS);
        }
    } catch (Exception e) {
        Message.add("Program exception while calculating proces performance metrics for the "
                + "simulation model:\n" + e.toString(), 2);
        e.printStackTrace();

    }
}

From source file:org.processmining.mining.fuzzymining.graph.transform.StatisticalCleanupTransformer.java

protected void print(SummaryStatistics stats) {
    System.out.println("min: " + stats.getMin());
    System.out.println("max: " + stats.getMax());
    System.out.println("mean: " + stats.getMean());
    System.out.println("geometr. mean: " + stats.getGeometricMean());
    System.out.println("standard deviation: " + stats.getStandardDeviation());
    System.out.println("variance: " + stats.getVariance());
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Add the calculated process time-metrics to the simulation model
 * @param logTraces ArrayList the process instances
 *///from  w w w. j  a  v  a  2 s  .  co  m
private void fillProcessHighLevelPN(ArrayList logTraces) {
    try {
        replayResult.calculateMetrics(logTraces, advancedSettings[0]);
        // add the arrival rate to the HighLevelProcess model
        double arrivalRate = (double) replayResult.getArrivalRate() * (double) timeDivider;
        SummaryStatistics arrivalStats = replayResult.getArrivalStats();

        HLGeneralDistribution dist = new HLGeneralDistribution(arrivalStats.getMean() / (double) timeDivider,
                arrivalStats.getMean() / (double) timeDivider,
                arrivalStats.getVariance() / (double) timeDivider, arrivalStats.getMin() / (double) timeDivider,
                arrivalStats.getMax() / (double) timeDivider, arrivalRate,
                HLDistribution.DistributionEnum.EXPONENTIAL_DISTRIBUTION);

        highLevelPN.getHLProcess().getGlobalInfo().setCaseGenerationScheme(dist);
        // set the time unit of the HighLevelProcess model
        // different time strings: "milliseconds", "seconds", "minutes", "hours", "days", "weeks", "months", "years"
        if (timeSort.equals("milliseconds")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MILLISECONDS);
        } else if (timeSort.equals("seconds")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.SECONDS);
        } else if (timeSort.equals("minutes")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MINUTES);
        } else if (timeSort.equals("hours")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.HOURS);
        } else if (timeSort.equals("days")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.DAYS);
        } else if (timeSort.equals("weeks")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.WEEKS);
        } else if (timeSort.equals("months")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.MONTHS);
        } else if (timeSort.equals("years")) {
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.YEARS);
        } else {
            // use default value
            highLevelPN.getHLProcess().getGlobalInfo().setTimeUnit(HLTypes.TimeUnit.HOURS);
        }
    } catch (Exception e) {
        Message.add("Program exception while calculating proces performance metrics for the "
                + "simulation model:\n" + e.toString(), 2);
        e.printStackTrace();

    }
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractCompoundDataset.java

@Override
public Number rootMeanSquare() {
    if (storedValues == null) {
        calculateSummaryStats();/*from   w w w .j  a v  a 2s .co m*/
    }

    double result = 0;
    for (int i = 0; i < isize; i++) {
        final SummaryStatistics stats = (SummaryStatistics) storedValues.get("stats-" + i);
        final double mean = stats.getMean();
        result += stats.getVariance() + mean * mean;
    }
    return Math.sqrt(result);
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractDataset.java

/**
 * Calculate summary statistics for a dataset along an axis
 *///from   w  w  w .  java 2 s .c o m
protected void calculateSummaryStats(final int axis) {
    int rank = getRank();

    int[] oshape = getShape();
    int alen = oshape[axis];
    oshape[axis] = 1;

    int[] nshape = new int[rank - 1];
    for (int i = 0; i < axis; i++) {
        nshape[i] = oshape[i];
    }
    for (int i = axis + 1; i < rank; i++) {
        nshape[i - 1] = oshape[i];
    }

    final int dtype = getDtype();
    IntegerDataset count = new IntegerDataset(nshape);
    AbstractDataset max = zeros(nshape, dtype);
    AbstractDataset min = zeros(nshape, dtype);
    IntegerDataset maxIndex = new IntegerDataset(nshape);
    IntegerDataset minIndex = new IntegerDataset(nshape);
    AbstractDataset sum = zeros(nshape, getLargestDType(dtype));
    DoubleDataset mean = new DoubleDataset(nshape);
    DoubleDataset var = new DoubleDataset(nshape);

    IndexIterator qiter = max.getIterator(true);
    int[] qpos = qiter.getPos();
    int[] spos = oshape.clone();

    while (qiter.hasNext()) {
        int i = 0;
        for (; i < axis; i++) {
            spos[i] = qpos[i];
        }
        spos[i++] = 0;
        for (; i < rank; i++) {
            spos[i] = qpos[i - 1];
        }

        final SummaryStatistics stats = new SummaryStatistics();
        for (int j = 0; j < alen; j++) {
            spos[axis] = j;
            final double val = getDouble(spos);
            if (Double.isInfinite(val) || Double.isNaN(val)) {
                continue;
            }

            stats.addValue(val);
        }

        count.setAbs(qiter.index, (int) stats.getN());

        final double amax = stats.getMax();
        max.setObjectAbs(qiter.index, amax);
        for (int j = 0; j < alen; j++) {
            spos[axis] = j;
            final double val = getDouble(spos);
            if (val == amax) {
                maxIndex.setAbs(qiter.index, j);
                break;
            }
        }
        final double amin = stats.getMin();
        min.setObjectAbs(qiter.index, amax);
        for (int j = 0; j < alen; j++) {
            spos[axis] = j;
            final double val = getDouble(spos);
            if (val == amin) {
                minIndex.setAbs(qiter.index, j);
                break;
            }
        }
        sum.setObjectAbs(qiter.index, stats.getSum());
        mean.setAbs(qiter.index, stats.getMean());
        var.setAbs(qiter.index, stats.getVariance());
    }
    setStoredValue("count-" + axis, count);
    storedValues.put("max-" + axis, max);
    storedValues.put("min-" + axis, min);
    storedValues.put("sum-" + axis, sum);
    storedValues.put("mean-" + axis, mean);
    storedValues.put("var-" + axis, var);
    storedValues.put("maxIndex-" + axis, maxIndex);
    storedValues.put("minIndex-" + axis, minIndex);
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractDataset.java

/**
 * The sample variance can be calculated in two ways: if the dataset is considered as the entire population then the
 * sample variance is simply the second central moment:
 * /*from   ww  w  . j av  a2  s  .co  m*/
 * <pre>
 *    sum((x_i - m)^2)/N
 * where {x_i} are set of N population values and m is the mean
 *    m = sum(x_i)/N
 * </pre>
 * 
 * Otherwise, if the dataset is a set of samples (with replacement) from the population then
 * 
 * <pre>
 *    sum((x_i - m)^2)/(N-1)
 * where {x_i} are set of N sample values and m is the unbiased estimate of the mean
 *    m = sum(x_i)/N
 * </pre>
 * 
 * Note that the second definition is also the unbiased estimator of population variance.
 * 
 * @param isDatasetWholePopulation
 * @return sample variance
 */
public Number variance(boolean isDatasetWholePopulation) {
    SummaryStatistics stats = getStatistics();

    if (isDatasetWholePopulation) {
        StorelessUnivariateStatistic oldVar = stats.getVarianceImpl();
        stats.setVarianceImpl(new Variance(false));
        Number var = stats.getVariance();
        stats.setVarianceImpl(oldVar);
        return var;
    }
    return stats.getVariance();
}