Example usage for org.apache.commons.math3.stat.descriptive StatisticalSummary getStandardDeviation

List of usage examples for org.apache.commons.math3.stat.descriptive StatisticalSummary getStandardDeviation

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive StatisticalSummary getStandardDeviation.

Prototype

double getStandardDeviation();

Source Link

Document

Returns the standard deviation of the available values.

Usage

From source file:org.briljantframework.example.array.Perf.java

private static double[] randmatstat_Briljant(int t) {
    Random random = new Random();
    int n = 5;//  w  w  w . ja  v  a  2  s  .  c  o  m
    DoubleArray p = Arrays.doubleArray(n, n * 4);
    DoubleArray q = Arrays.doubleArray(n * 2, n * 2);
    DoubleArray v = Arrays.doubleArray(t, 1);
    DoubleArray w = Arrays.doubleArray(t, 1);

    for (int i = 0; i < t; i++) {
        p.getView(0, 0, n, n).assign(random::nextGaussian);
        p.getView(0, n, n, n).assign(random::nextGaussian);
        p.getView(0, n * 2, n, n).assign(random::nextGaussian);
        p.getView(0, n * 3, n, n).assign(random::nextGaussian);

        q.getView(0, 0, n, n).assign(random::nextGaussian);
        q.getView(0, n, n, n).assign(random::nextGaussian);
        q.getView(n, 0, n, n).assign(random::nextGaussian);
        q.getView(n, n, n, n).assign(random::nextGaussian);

        DoubleArray x = Arrays.dot(TRANSPOSE, KEEP, p, p);
        v.set(i, Arrays.trace(Arrays.dot(x, Arrays.dot(x, x))));

        x = Arrays.dot(TRANSPOSE, KEEP, q, q);
        w.set(i, Arrays.trace(Arrays.dot(x, Arrays.dot(x, x))));
    }
    StatisticalSummary statV = v.collect(FastStatistics::new, FastStatistics::addValue);
    StatisticalSummary statW = w.collect(FastStatistics::new, FastStatistics::addValue);
    double meanv = statV.getMean();
    double stdv = statV.getStandardDeviation();
    double meanw = statW.getMean();
    double stdw = statW.getStandardDeviation();

    return new double[] { meanv, stdv, meanw, stdw };
}

From source file:prm4jeval.dataanalysis.ConfidenceInterval.java

public static double getConfidenceIntervalWidth(StatisticalSummary summaryStatistics, double significance) {
    RealDistribution tDist = new TDistribution(summaryStatistics.getN() - 1);
    double t = tDist.inverseCumulativeProbability(1.0 - significance / 2);
    return 2 * t * summaryStatistics.getStandardDeviation() / Math.sqrt(summaryStatistics.getN());
}