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

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

Introduction

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

Prototype

public double getStandardDeviation() 

Source Link

Document

Returns the standard deviation of the available values.

Usage

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*from  ww w.  j ava2 s .co m*/
@Test
public void testAggregatedPlateIndices() {

    for (PlateInteger plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(deviation.platesAggregated(plate, begin, end - begin),
                precision);

        for (WellInteger well : plate) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = Precision.round(statAggregated.getStandardDeviation(), precision);

        assertTrue(aggregatedResult == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*from ww w .j a  v  a 2s.com*/
@Test
public void testAggregatedSetIndices() {

    for (PlateInteger plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision
                .round(deviation.setsAggregated(plate.dataSet(), begin, end - begin), precision);

        for (WellInteger well : plate) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getStandardDeviation(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection.// w  w  w.ja v  a  2 s .  c  o m
 */
@Test
public void testAggregatedSetCollectionIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    List<WellSetInteger> collection = new ArrayList<WellSetInteger>();

    for (PlateInteger plate : arrayIndices) {
        collection.add(plate.dataSet());
    }

    Map<WellSetInteger, Double> aggregatedReturnedMap = deviation.setsAggregated(collection, begin,
            end - begin);
    Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>();

    for (WellSetInteger set : collection) {

        List<Double> resultList = new ArrayList<Double>();

        for (WellInteger well : set) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getStandardDeviation();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetInteger set : collection) {

        double result = Precision.round(aggregatedResultMap.get(set), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(set), precision);

        assertTrue(result == returned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the array.//from   w  w w.  j  a va 2 s . c o  m
 */
@Test
public void testAggregatedSetArrayIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    WellSetInteger[] setArrayIndices = new WellSetInteger[arrayIndices.length];

    for (int i = 0; i < setArrayIndices.length; i++) {
        setArrayIndices[i] = arrayIndices[i].dataSet();
    }

    Map<WellSetInteger, Double> aggregatedReturnedMap = deviation.setsAggregated(setArrayIndices, begin,
            end - begin);
    Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>();

    for (WellSetInteger set : setArrayIndices) {

        List<Double> resultList = new ArrayList<Double>();

        for (WellInteger well : set) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getStandardDeviation();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetInteger plate : setArrayIndices) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

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

/**
 * Tests well calculation using indices.
 *//*  w  w  w .j av  a2s. co  m*/
@Test
public void testWellIndices() {

    for (Plate plate : arrayIndices) {

        for (Well well : plate) {

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

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

            int size = arrayIndices[0].first().size();
            int begin = random.nextInt(size - 5);
            int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = Precision.round(stat.getStandardDeviation(), precision);
            double returned = Precision.round(deviation.well(well, begin, end - begin), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation using indices.
 *///from w ww  .  j  a v a2s  . c o m
@Test
public void testWellIndices() {

    for (PlateDouble plate : arrayIndices) {

        for (WellDouble well : plate) {

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

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

            int size = arrayIndices[0].first().size();
            int begin = random.nextInt(size - 5);
            int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = Precision.round(stat.getStandardDeviation(), precision);
            double returned = Precision.round(deviation.well(well, begin, end - begin), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation using indices.
 *///from ww w  .  ja v  a  2  s. co  m
@Test
public void testWellIndices() {

    for (PlateInteger plate : arrayIndices) {

        for (WellInteger well : plate) {

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

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

            int size = arrayIndices[0].first().size();
            int begin = random.nextInt(size - 5);
            int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = Precision.round(stat.getStandardDeviation(), precision);
            double returned = Precision.round(deviation.well(well, begin, end - begin), precision);

            assertTrue(result == returned);
        }
    }
}

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));
        }//from   w w  w  .ja  v a  2 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:classifiers.ComplexClassifierZufall.java

@Override
public void BewertunginProzent() throws Exception {
    /*  if (Model.getAnzahlkanten() != 0) {
    System.out.println("Parameter:" + "Vernetzungsprozent:" + this.vernetzung + "(" + (Model.getMoeglischeAnzahlKanten() * vernetzung) / Model.getAnzahlkanten()
            + ")," + " " + "Anzahldurchlauf:" + this.anzahldurchlauf + "    " + "max Anzahlkanten:" + Model.getAnzahlkanten() + "(" + Model.getMoeglischeAnzahlKanten() + " )");
      } else {/*from ww  w . jav  a  2  s.c o  m*/
    System.out.println("Parameter:" + "Vernetzungsprozent:" + this.vernetzung + "(" + (Model.getMoeglischeAnzahlKanten() * vernetzung)
            + ")," + " " + "Anzahldurchlauf:" + this.anzahldurchlauf + "    " + "max Anzahlkanten:" + Model.getAnzahlkanten() + "(" + Model.getMoeglischeAnzahlKanten() + " )");
      }
      System.out.println("----------------------------------------------------------------------------------------");*/

    double count = 0;
    double[][] bestergeb = new double[1][2];
    double max = 100;
    double[][] hilf;
    double[][] hilf2;

    double[] erg = new double[5];

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

        Bootstrap(Modelmenge);
        train(this.traindaten);
        // System.out.println("training NR" + " " + i + ":");
        // System.out.println("trainingsdeaten:");
        hilf = new double[1][2];
        hilf2 = new double[1][2];

        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) (this.trainergebnisse[i][0] * 100) / 100 + "%" + "  " + "Dauer:" + " " + (int) (this.trainergebnisse[i][1]) + "ms");

        hilf2 = test(testdaten);

        this.testergebnisse[i][0] = hilf2[0][0];
        this.testergebnisse[i][1] = hilf2[0][1];
        /* if(testergebnisse[i][0]<=max)
         {
         max=testergebnisse[i][0];
         bestemodel=Model;
         bestergeb[0][0]=testergebnisse[i][0];
         bestergeb[0][1]=testergebnisse[i][1];
                
         }*/

        //System.out.println("Validierung NR" + " " + i + ":");
        //System.out.println("Validierungsngsdaten:");

        // System.out.println("Fehlerquote Validierungs NR" + " " + i + ":" + " " + (double) (int) (this.testergebnisse[i][0] * 100) / 100 + "%" + "  " + "Dauer:" + " " + (int) (this.testergebnisse[i][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));

    // System.out.println("Mittlere Fehlerquote der Validierungsmengen:" + " " + (double) (int) (Mittlerevalidierungsquote * 100) / 100 + "%" + "(" + (double) (int) ((stadartdeviationvalidierung / Math.sqrt(anzahldurchlauf)) * 100) / 100 + "%)");
    //System.out.println("Mittlere Dauer der Validierung :" + " " + (int) (Mittlerezeit) + " " + "ms" + "(" + (int) ((standartdeviationtime / Math.sqrt(anzahldurchlauf))) + "ms)");
    erg[0] = vernetzung;
    erg[1] = (double) (int) (Mittlerevalidierungsquote * 100) / 100;
    erg[2] = Mittlerezeit;
    erg[3] = (double) (int) ((stadartdeviationvalidierung / Math.sqrt(anzahldurchlauf)) * 100) / 100;
    erg[4] = (int) ((standartdeviationtime / Math.sqrt(anzahldurchlauf)));

    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];
    struct.setErgebnisse(erg);
    /* 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");
    /* System.out.println();
      System.out.println("Beste Struktur:"+"  "+"Validierung:"+" "+(int)bestergeb[0][0]+"%"+"  "+"Zeit:"+" "+(int)bestergeb[0][1]+"ms");
      System.out.println("---------------------------------------------------------------------------------------");
      bestemodel=Model; if(bestemodel!=null) bestemodel.ToString();*/

}

From source file:com.github.jessemull.microflex.stat.statbigdecimal.StandardDeviationBigDecimalTest.java

/**
 * Tests well calculation./*from w  ww  .  j a v  a2s . c om*/
 */
@Test
public void testWell() {

    for (PlateBigDecimal plate : array) {

        for (WellBigDecimal well : plate) {

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

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getStandardDeviation();

            BigDecimal returned = deviation.well(well, mc);
            BigDecimal result = new BigDecimal(resultDouble);

            BigDecimal[] corrected = correctRoundingErrors(returned, result);

            assertEquals(corrected[0], corrected[1]);
        }
    }
}