Example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getElement

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

Introduction

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

Prototype

public double getElement(int index) 

Source Link

Document

Returns the element at the specified index

Usage

From source file:org.bml.util.rt.telemetry.SecondBasedCounterTest.java

/**
 * Test of getLastMinutesTelemetry method, of class SecondBasedCounter.
 *///from  www  .  j  av a 2s  .  c o  m
public void testGetLastMinutesTelemetry() {
    System.out.println("getLastMinutesTelemetry");
    DescriptiveStatistics stats = counter.getLastMinutesTelemetry();

    long max = stats.getN();

    AtomicInteger[] counterArray = counter.getCounterArray();

    for (int index = 0; index < max; index++) {
        System.out.println(stats.getElement(index) + " -- " + counterArray[index].get());

    }

}

From source file:Pooling.collectStatsTime.java

public static void main(String[] args) throws IOException {
    /*         int maxN = 1000;
             double[] prob = {0.25,0.5,0.75,1.00};
             int[] maxPoolSize = {35};/*from   w  w  w  .  j  a va2  s .co  m*/
             int nTests = 50;
                     
             String folder = "randGraphsSimRes";
             for (int t = 0; t < maxPoolSize.length; t++)
             {
     FileWriter fw = new FileWriter(folder + File.separator + "statsDesignTime" + maxPoolSize[t] + ".txt");
     for (int n = 10; n <= maxN; n+=10)
     {
         DescriptiveStatistics stats = new DescriptiveStatistics();
         for (int i = 1; i <= nTests; i++)
         {
             String resfile = "testResults_" + n + "_" + maxPoolSize[t] + "_" + i + ".txt";
             BufferedReader br = new BufferedReader(new FileReader(folder + File.separator + resfile));
             System.out.println(resfile);
             String s = br.readLine();
             StringTokenizer st = new StringTokenizer(s," ");
             st.nextToken();
             int k = Integer.parseInt(st.nextToken());
             stats.addValue(((double)k)/1000);
         }
         fw.write(n + " " + stats.getMean() + " " + (stats.getStandardDeviation()/Math.sqrt(nTests)) +  "\n");
     }
     fw.close();
             } */

    int[] ns = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 };
    int[] maxPoolSizes = { 15, 25, 35 };
    int nTests = 10;
    for (int sz = 0; sz < maxPoolSizes.length; sz++) {
        FileWriter fw = new FileWriter("statisticsTime_" + maxPoolSizes[sz] + ".txt");
        for (int in = 0; in < ns.length; in++) {
            DescriptiveStatistics stats = new DescriptiveStatistics();
            for (int it = 0; it < nTests; it++) {
                String outdir = "Test_" + maxPoolSizes[sz] + "_" + ns[in] + "_" + it;
                String repFile = outdir + File.separator + "report.txt";
                System.out.println(outdir);
                BufferedReader br = new BufferedReader(new FileReader(repFile));
                String s = "";
                for (int i = 0; i < 6; i++)
                    s = br.readLine();
                StringTokenizer st = new StringTokenizer(s, ":");
                st.nextToken();
                double tm = Double.parseDouble(st.nextToken());
                stats.addValue(tm);
            }
            double maxtime = stats.getMax();
            DescriptiveStatistics stats1 = new DescriptiveStatistics();
            for (int i = 0; i < nTests; i++)
                if (stats.getElement(i) != maxtime)
                    stats1.addValue(stats.getElement(i));
            fw.write(ns[in] + " " + stats1.getMean() + " "
                    + (stats1.getStandardDeviation() / Math.sqrt((nTests - 1))) + "\n");
        }
        fw.close();
    }
}