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

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

Introduction

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

Prototype

public double getMean() 

Source Link

Document

Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm"> arithmetic mean </a> of the available values

Usage

From source file:classifiers.Simpleclassifier.java

@Override
public void BewertunginProzent() throws Exception {
    System.out.println("Parameter:" + "Anzahldurchlauf:" + this.anzahldurchlauf);
    //System.out.println("----------------------------------------------------------------------------------------");
    double count = 0;
    double max = 0;
    double[][] hilf = new double[1][2];
    double[][] hilf2 = new double[1][2];

    for (int i = 0; i < anzahldurchlauf; i++) {

        Bootstrap(Modelmenge);// w ww.  j  av a2 s.com
        train(this.traindaten);
        // System.out.println("training NR" + " " + i + ":");
        // System.out.println("trainingsdeaten:");

        hilf = test(traindaten);

        this.trainergebnisse[i][0] = hilf[0][0];
        this.trainergebnisse[i][1] = hilf[0][1];
        //System.out.println("Fehlerquote TrainingNR" + " " + i + ":" + " " + (double)(int) (hilf[0][0]*100)/100 + "%" + "  " + "Dauer:" + " " + (int) hilf[0][1]  + "ms");

        hilf2 = test(testdaten);

        this.testergebnisse[i][0] = hilf2[0][0];
        this.testergebnisse[i][1] = hilf2[0][1];
        // System.out.println("Validierung NR" + " " + i + ":");
        //System.out.println("Validierungsngsdaten:");

        // System.out.println("Fehlerquote Validierungs NR" + " " + i + ":" + " " + (double)(int) (hilf2[0][0]*100)/100 + "%" + "  " + "Dauer:" + " " + (int) hilf2[0][1]  + "ms");
        //System.out.println("----------------------------------------------------------------------------------------");

    }

    DescriptiveStatistics stats1 = new DescriptiveStatistics();
    DescriptiveStatistics stat1 = new DescriptiveStatistics();

    // Add the data from the array
    for (int i = 0; i < trainergebnisse.length; i++) {

        stats1.addValue(trainergebnisse[i][0]);
        stat1.addValue(trainergebnisse[i][1]);
    }

    double mean1 = stats1.getMean();
    double std1 = stats1.getStandardDeviation();
    double meanzeit1 = stat1.getMean();
    double stdzeit1 = stat1.getStandardDeviation();

    // System.out.println("Mittlere Felehrquote des Tainings:" + " " + (double)(int) (mean1*100)/100 + "%" + "(" + (double)(int) ((std1 / Math.sqrt(anzahldurchlauf))*100)/100 + "%)");
    //System.out.println("Mittlere Dauer des trainings:" + " " + (int) meanzeit1  + " " + "ms" + "(" + (int) ((stdzeit1 / Math.sqrt(anzahldurchlauf)) ) + "ms)");
    //System.out.println("--------------------------------------------------------------------------------------");

    DescriptiveStatistics stats = new DescriptiveStatistics();
    DescriptiveStatistics stat = new DescriptiveStatistics();

    // Add the data from the array
    for (int i = 0; i < testergebnisse.length; i++) {

        stats.addValue(testergebnisse[i][0]);
        stat.addValue(testergebnisse[i][1]);
    }

    this.Mittlerevalidierungsquote = stats.getMean();
    this.stadartdeviationvalidierung = (int) (stats.getStandardDeviation() / Math.sqrt(anzahldurchlauf));
    this.Mittlerezeit = stat.getMean();
    this.standartdeviationtime = (int) (stat.getStandardDeviation() / Math.sqrt(anzahldurchlauf));
    ergb[1] = Mittlerevalidierungsquote;
    ergb[2] = Mittlerezeit;
    ergb[3] = (double) (int) ((stadartdeviationvalidierung / Math.sqrt(anzahldurchlauf)) * 100) / 100;
    ergb[4] = (int) ((standartdeviationtime / Math.sqrt(anzahldurchlauf)));

    struct.setErgebnisse(ergb);
    /*  System.out.println("Durchnittliche Fehlerquote der Validierungsmengen:" + " " + (int) Mittlerevalidierungsquote + "%" + "(" + (int) (stadartdeviationvalidierung / Math.sqrt(anzahldurchlauf)) + "%)");
      System.out.println("durchnittliche Dauer der Validierung :" + " " + (int) (Mittlerezeit)  + " " + "ms" + "(" + (int) ((standartdeviationtime / Math.sqrt(anzahldurchlauf)) ) + "ms)");*/

    train(this.Modelmenge);
    hilf = test(Modelmenge);
    this.Modelergebnisse[0][0] = hilf[0][0];
    this.Modelergebnisse[0][1] = hilf[0][1];
    hilf = test(validierungsmenge);
    validierungsergebnisse[0][0] = hilf[0][0];
    validierungsergebnisse[0][1] = hilf[0][1];
    /* System.out.println("---------------------------------------------------------------------------------------");*/

    // System.out.println("Fehlerquote der  training auf dem Datensatz:" + "  " + (double)(int) (Modelergebnisse[0][0]*100)/100 + "%");
    // System.out.println("Zeit des trainings (Datensatz):" + " " + (int) (Modelergebnisse[0][1] ) + " " + "ms");
    // System.out.println("---------------------------------------------------------------------------------------");
    // System.out.println("Fehlerquote der Test:" + "  " + (double)(int) (validierungsergebnisse[0][0]*100)/100 + "%");
    // System.out.println("Zeit der Test:" + " " + (int) (validierungsergebnisse[0][1] ) + " " + "ms");

    /* Instances bestmodel=new Instances(Modelmenge,bestmodelindexen.length);
     double result;
     for(int i=0;i<bestmodelindexen.length;i++)
     {
     bestmodel.add(Modelmenge.instance(bestmodelindexen[i]));
     }
     train(bestmodel);
            
            
            
     result= test(validierungsmenge);
     System.out.println();
     System.out.println("der Beste Model  ist:");
     System.out.println("-----------------------------------------");
     System.out.println(bestmodel);
     System.out.println("mit eine Leistung von:"+"   "+result+"%");
               
               
               
               
               
     return result;
            
     }*/
}

From source file:com.loadtesting.core.data.TimeSerieData.java

public TimeSerieData(String name, List<TimeSample> samples, CapturerConfig config) {
    this.name = name;
    this.unit = config.getUnit();
    this.volume = samples.size();
    if (volume > 0) {
        TimeSample first = samples.get(0);
        this.unit = first.getTimeUnit();
        this.opening = first.getTime(unit);
        TimeSample last = samples.get(volume - 1);
        this.closing = last.getTime(unit);
        this.samples = config.getFilter().filter(samples);

        DescriptiveStatistics stats = new DescriptiveStatistics(volume);
        for (TimeSample timeSample : samples) {
            stats.addValue(timeSample.getTime(unit));
        }//w w  w .ja va2 s. c o  m
        this.high = stats.getMax();
        this.low = stats.getMin();
        this.median = (high + low) / 2;
        this.typical = (high + low + closing) / 3;
        this.weightedClose = (high + low + closing + closing) / 4;
        this.sma = stats.getMean();
        this.variance = stats.getVariance();
        this.sd = stats.getStandardDeviation();
        this.sum = stats.getSum();
        this.sumsq = stats.getSumsq();
        this.skewness = stats.getSkewness();
        this.kurtosis = stats.getKurtosis();
        this.geometricMean = stats.getGeometricMean();
        this.populationVariance = stats.getPopulationVariance();
    } else {
        this.samples = samples;
    }
}

From source file:gdsc.smlm.ij.plugins.PSFEstimator.java

private void setParams(int i, double[] params, double[] params_dev, DescriptiveStatistics sample) {
    if (sample.getN() > 0) {
        params[i] = sample.getMean();
        params_dev[i] = sample.getStandardDeviation();
    }/*  w w  w .j  av  a  2  s  . c om*/
}

From source file:com.github.jessemull.microflexdouble.stat.MeanTest.java

/**
 * Tests the plate statistics method./* w w  w .j av  a  2 s  . c  om*/
 */
@Test
public void testPlate() {

    for (Plate plate : array) {

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = mean.plate(plate);

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statdouble.MeanDoubleTest.java

/**
 * Tests the plate statistics method./*from  w w w .  j  ava 2  s . c  o m*/
 */
@Test
public void testPlate() {

    for (PlateDouble plate : array) {

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = mean.plate(plate);

        for (WellDouble well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (WellDouble well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statinteger.MeanIntegerTest.java

/**
 * Tests the plate statistics method./*from  ww  w  . j  a v a 2 s.  c  o m*/
 */
@Test
public void testPlate() {

    for (PlateInteger plate : array) {

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = mean.plate(plate);

        for (WellInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (WellInteger well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexdouble.stat.MeanTest.java

/**
 * Tests set calculation.//from   w w  w  .  j a v  a  2s.c  o m
 */
@Test
public void testSet() {

    for (Plate plate : array) {

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = mean.set(plate.dataSet());

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }

}

From source file:com.github.jessemull.microflex.stat.statdouble.MeanDoubleTest.java

/**
 * Tests set calculation./*from   ww  w  . j ava 2  s .c  o m*/
 */
@Test
public void testSet() {

    for (PlateDouble plate : array) {

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = mean.set(plate.dataSet());

        for (WellDouble well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (WellDouble well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }

}

From source file:com.github.jessemull.microflex.stat.statinteger.MeanIntegerTest.java

/**
 * Tests set calculation.//from w  w  w  .  j  av  a2s  . c  om
 */
@Test
public void testSet() {

    for (PlateInteger plate : array) {

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = mean.set(plate.dataSet());

        for (WellInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getMean();

            resultMap.put(well, result);
        }

        for (WellInteger well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }

}

From source file:de.iisys.schub.processMining.similarity.AlgoController.java

private String showDocMetaData(List<Double> cosineSimValues) {
    DescriptiveStatistics stat = new DescriptiveStatistics();

    for (int i = 0; i < cosineSimValues.size(); i++) {
        stat.addValue(cosineSimValues.get(i));
    }/*from   ww w .  j  av  a 2s  .c o m*/

    double min = Math.round(stat.getMin() * 1000) / 1000.0;
    double max = Math.round(stat.getMax() * 1000) / 1000.0;
    double arithMean = Math.round(stat.getMean() * 10000) / 10000.0;
    double percentile = Math.round(stat.getPercentile(PERCENTILE) * 1000) / 1000.0;

    DecimalFormat df = new DecimalFormat("#00.00");
    String meta = "Min: " + df.format(min * 100) + " %" + ", Max: " + df.format(max * 100) + " %"
            + ", Arith. Mean: " + df.format(arithMean * 100) + " %" + ", Percentile (" + PERCENTILE + " %): "
            + df.format(percentile * 100) + " %";

    return meta;
}