Example usage for org.apache.commons.math3.stat.descriptive SummaryStatistics SummaryStatistics

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

Introduction

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

Prototype

public SummaryStatistics() 

Source Link

Document

Construct a SummaryStatistics instance

Usage

From source file:com.sop4j.SimpleStatistics.java

public static void main(String[] args) {
    final MersenneTwister rng = new MersenneTwister(); // used for RNG... READ THE DOCS!!!
    final int[] values = new int[NUM_VALUES];

    final DescriptiveStatistics descriptiveStats = new DescriptiveStatistics(); // stores values
    final SummaryStatistics summaryStats = new SummaryStatistics(); // doesn't store values
    final Frequency frequency = new Frequency();

    // add numbers into our stats
    for (int i = 0; i < NUM_VALUES; ++i) {
        values[i] = rng.nextInt(MAX_VALUE);

        descriptiveStats.addValue(values[i]);
        summaryStats.addValue(values[i]);
        frequency.addValue(values[i]);/*from www  .j  a va2 s .c o m*/
    }

    // print out some standard stats
    System.out.println("MIN: " + summaryStats.getMin());
    System.out.println("AVG: " + String.format("%.3f", summaryStats.getMean()));
    System.out.println("MAX: " + summaryStats.getMax());

    // get some more complex stats only offered by DescriptiveStatistics
    System.out.println("90%: " + descriptiveStats.getPercentile(90));
    System.out.println("MEDIAN: " + descriptiveStats.getPercentile(50));
    System.out.println("SKEWNESS: " + String.format("%.4f", descriptiveStats.getSkewness()));
    System.out.println("KURTOSIS: " + String.format("%.4f", descriptiveStats.getKurtosis()));

    // quick and dirty stats (need a little help from Guava to convert from int[] to double[])
    System.out.println("MIN: " + StatUtils.min(Doubles.toArray(Ints.asList(values))));
    System.out.println("AVG: " + String.format("%.4f", StatUtils.mean(Doubles.toArray(Ints.asList(values)))));
    System.out.println("MAX: " + StatUtils.max(Doubles.toArray(Ints.asList(values))));

    // some stats based upon frequencies
    System.out.println("NUM OF 7s: " + frequency.getCount(7));
    System.out.println("CUMULATIVE FREQUENCY OF 7: " + frequency.getCumFreq(7));
    System.out.println("PERCENTAGE OF 7s: " + frequency.getPct(7));
}

From source file:it.cnr.isti.smartfed.test.TestResult.java

public static void reset() {
    allocationTime = new SummaryStatistics();
    mappingTime = new SummaryStatistics();
    berger = new SummaryStatistics();
    cost = new SummaryStatistics();
    failures = new SummaryStatistics();
    vmDifference = new SummaryStatistics();
    lockDegree = new SummaryStatistics();
}

From source file:cn.edu.suda.core.stats.StatsUtils.java

public static DataMatrix addTTest(DataMatrix dm, int m, int n) {
    int col = dm.getDcol();
    dm.addCols(2);//from   w  ww  .  j  a v a  2s .co  m
    dm.setColname(col, "ABS_t_value");
    dm.setColname(col + 1, "P_value");
    for (int i = 0; i < dm.getDrow(); i++) {
        double[] array = dm.getRow(i);
        SummaryStatistics stats1 = new SummaryStatistics();
        SummaryStatistics stats2 = new SummaryStatistics();
        for (int j = 0; j < m; j++) {
            stats1.addValue(array[j]);
        }
        for (int j = m; j < m + n; j++) {
            stats2.addValue(array[j]);
        }
        double var1 = stats1.getVariance();
        double var2 = stats2.getVariance();
        if (var1 == 0 && var2 == 0) {
            dm.setValue(i, col, 0);
            dm.setValue(i, col + 1, 1);
        } else {
            double t = Math.abs(TestUtils.t(stats1, stats2));
            double p = TestUtils.tTest(stats1, stats2);
            t = Utils.formatNumber(t, 4);
            p = Utils.formatNumber(p, 4);
            dm.setValue(i, col, t);
            dm.setValue(i, col + 1, p);
        }
    }
    return dm;
}

From source file:com.trickl.stats.GammaDistributionOutlier.java

@Override
public IntPredicate apply(int[] edgeFlows) {
    // Calculate the distribution of flow across edges
    SummaryStatistics flowSummaryStatistics = new SummaryStatistics();
    for (int flow : edgeFlows) {
        flowSummaryStatistics.addValue(flow);
    }/*  w  w  w. ja  v  a  2 s . c  o  m*/
    double flowVar = flowSummaryStatistics.getVariance();
    double flowMean = flowSummaryStatistics.getMean();
    double gammaShape = (flowMean * flowMean) / flowVar;
    double gammaScale = flowVar / flowMean;
    GammaDistribution gammaDistribution = new GammaDistribution(gammaShape, gammaScale);
    return new ValueAboveHasProbabilityBelow(gammaDistribution, probability);
}

From source file:com.dattack.dbping.report.GroupStats.java

public GroupStats(final int group) {
    this.group = group;
    this.statistics = new SummaryStatistics();
}

From source file:com.qwazr.search.bench.test.TestResults.java

public void add(Object testClass, Integer rate) {
    statsMap.computeIfAbsent(testClass.getClass().getName(), (key) -> new SummaryStatistics()).addValue(rate);
}

From source file:nars.util.meter.func.BasicStatistics.java

public void setWindowSize(int w) {
    stat = w == 0 ? new SummaryStatistics() : new DescriptiveStatistics(w);
}

From source file:de.tudarmstadt.ukp.dkpro.core.performance.PerformanceTestUtil.java

public static SummaryStatistics measurePerformance(AnalysisEngineDescription aWriterDesc,
        Iterable<JCas> aTestData) throws ResourceInitializationException, AnalysisEngineProcessException {
    AnalysisEngine writer = createEngine(aWriterDesc);

    SummaryStatistics stats = new SummaryStatistics();

    for (JCas jcas : aTestData) {
        long begin = System.currentTimeMillis();
        writer.process(jcas);/*from   www  . j  a  va2s.com*/
        stats.addValue(System.currentTimeMillis() - begin);
    }

    writer.collectionProcessComplete();
    writer.destroy();

    return stats;
}

From source file:ijfx.plugins.MeanProjection.java

@Override
public <T extends RealType<T>> void process(List<T> list, Sampler<T> sampler) {
    SummaryStatistics summaryStatistics = new SummaryStatistics();
    list.stream().forEach((t) -> summaryStatistics.addValue(t.getRealDouble()));

    //Set result//from   w w w  .  ja  va  2  s. c  o m
    sampler.get().setReal(summaryStatistics.getMean());

}

From source file:mop.MemoryLogger.java

MemoryLogger() {
    if (STATS_LOGGING) {
        memStats = new SummaryStatistics();
        String outputPath = "logs/javamop-stats.log";
        System.out.println("Logging activated. Output path: " + outputPath);
        experimentName = getMandatorySystemProperty("prm4jeval.invocation") + " "
                + getMandatorySystemProperty("prm4jeval.benchmark") + " "
                + getMandatorySystemProperty("prm4jeval.paramProperty");
        logger = getFileLogger(outputPath);
    } else {//ww w.  j  av  a  2  s  .co  m
        System.out.println("Memory logging not activated.");
    }
}