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.fpuna.preproceso.PreprocesoTS.java

private static void calculoFeatures(Registro[] muestras, String activity) {

    DescriptiveStatistics stats_x = new DescriptiveStatistics();
    DescriptiveStatistics stats_y = new DescriptiveStatistics();
    DescriptiveStatistics stats_z = new DescriptiveStatistics();
    //DescriptiveStatistics stats_m1 = new DescriptiveStatistics();
    //DescriptiveStatistics stats_m2 = new DescriptiveStatistics();
    double[] fft_x;
    double[] fft_y;
    double[] fft_z;
    double[] AR_4;

    for (int i = 0; i < muestras.length; i++) {
        stats_x.addValue(muestras[i].getValor_x());
        stats_y.addValue(muestras[i].getValor_y());
        stats_z.addValue(muestras[i].getValor_z());
    }/*w  w w.j  a va 2  s  .  com*/

    //********* FFT *********
    fft_x = Util.transform(stats_x.getValues());
    fft_y = Util.transform(stats_y.getValues());
    fft_z = Util.transform(stats_z.getValues());

    //******************* Eje X *******************//
    //mean(s) - Arithmetic mean
    System.out.print(stats_x.getMean() + ",");
    //std(s) - Standard deviation
    System.out.print(stats_x.getStandardDeviation() + ",");
    //mad(s) - Median absolute deviation
    //
    //max(s) - Largest values in array
    System.out.print(stats_x.getMax() + ",");
    //min(s) - Smallest value in array
    System.out.print(stats_x.getMin() + ",");
    //skewness(s) - Frequency signal Skewness
    System.out.print(stats_x.getSkewness() + ",");
    //kurtosis(s) - Frequency signal Kurtosis
    System.out.print(stats_x.getKurtosis() + ",");
    //energy(s) - Average sum of the squares
    System.out.print(stats_x.getSumsq() / stats_x.getN() + ",");
    //entropy(s) - Signal Entropy
    System.out.print(Util.calculateShannonEntropy(fft_x) + ",");
    //iqr (s) Interquartile range
    System.out.print(stats_x.getPercentile(75) - stats_x.getPercentile(25) + ",");
    try {
        //autoregression (s) -4th order Burg Autoregression coefficients
        AR_4 = AutoRegression.calculateARCoefficients(stats_x.getValues(), 4, true);
        System.out.print(AR_4[0] + ",");
        System.out.print(AR_4[1] + ",");
        System.out.print(AR_4[2] + ",");
        System.out.print(AR_4[3] + ",");
    } catch (Exception ex) {
        Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex);
    }
    //meanFreq(s) - Frequency signal weighted average
    System.out.print(Util.meanFreq(fft_x, stats_x.getValues()) + ",");

    //******************* Eje Y *******************//
    //mean(s) - Arithmetic mean
    System.out.print(stats_y.getMean() + ",");
    //std(s) - Standard deviation
    System.out.print(stats_y.getStandardDeviation() + ",");
    //mad(s) - Median absolute deviation
    //
    //max(s) - Largest values in array
    System.out.print(stats_y.getMax() + ",");
    //min(s) - Smallest value in array
    System.out.print(stats_y.getMin() + ",");
    //skewness(s) - Frequency signal Skewness
    System.out.print(stats_y.getSkewness() + ",");
    //kurtosis(s) - Frequency signal Kurtosis
    System.out.print(stats_y.getKurtosis() + ",");
    //energy(s) - Average sum of the squares
    System.out.print(stats_y.getSumsq() / stats_y.getN() + ",");
    //entropy(s) - Signal Entropy
    System.out.print(Util.calculateShannonEntropy(fft_y) + ",");
    //iqr (s) Interquartile range
    System.out.print(stats_y.getPercentile(75) - stats_y.getPercentile(25) + ",");
    try {
        //autoregression (s) -4th order Burg Autoregression coefficients
        AR_4 = AutoRegression.calculateARCoefficients(stats_y.getValues(), 4, true);
        System.out.print(AR_4[0] + ",");
        System.out.print(AR_4[1] + ",");
        System.out.print(AR_4[2] + ",");
        System.out.print(AR_4[3] + ",");
    } catch (Exception ex) {
        Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex);
    }
    //meanFreq(s) - Frequency signal weighted average
    System.out.print(Util.meanFreq(fft_y, stats_y.getValues()) + ",");

    //******************* Eje Z *******************//
    //mean(s) - Arithmetic mean
    System.out.print(stats_z.getMean() + ",");
    //std(s) - Standard deviation
    System.out.print(stats_z.getStandardDeviation() + ",");
    //mad(s) - Median absolute deviation
    //
    //max(s) - Largest values in array
    System.out.print(stats_z.getMax() + ",");
    //min(s) - Smallest value in array
    System.out.print(stats_z.getMin() + ",");
    //skewness(s) - Frequency signal Skewness
    System.out.print(stats_z.getSkewness() + ",");
    //kurtosis(s) - Frequency signal Kurtosis
    System.out.print(stats_z.getKurtosis() + ",");
    //energy(s) - Average sum of the squares
    System.out.print(stats_z.getSumsq() / stats_z.getN() + ",");
    //entropy(s) - Signal Entropy
    System.out.print(Util.calculateShannonEntropy(fft_z) + ",");
    //iqr (s) Interquartile range
    System.out.print(stats_z.getPercentile(75) - stats_z.getPercentile(25) + ",");
    try {
        //autoregression (s) -4th order Burg Autoregression coefficients
        AR_4 = AutoRegression.calculateARCoefficients(stats_z.getValues(), 4, true);
        System.out.print(AR_4[0] + ",");
        System.out.print(AR_4[1] + ",");
        System.out.print(AR_4[2] + ",");
        System.out.print(AR_4[3] + ",");
    } catch (Exception ex) {
        Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex);
    }
    //meanFreq(s) - Frequency signal weighted average
    System.out.print(Util.meanFreq(fft_z, stats_z.getValues()) + ",");

    //******************* Feature combinados *******************/
    //sma(s1; s2; s3) - Signal magnitude area
    System.out.print(Util.sma(stats_x.getValues(), stats_y.getValues(), stats_z.getValues()) + ",");
    //correlation(s1; s2) - Pearson Correlation coefficient
    System.out.print(new PearsonsCorrelation().correlation(stats_x.getValues(), stats_y.getValues()) + ",");
    System.out.print(new PearsonsCorrelation().correlation(stats_x.getValues(), stats_z.getValues()) + ",");
    System.out.print(new PearsonsCorrelation().correlation(stats_y.getValues(), stats_z.getValues()) + ",");

    //******************* Actividad *******************/
    System.out.print(activity);
    System.out.print("\n");
}

From source file:io.prestosql.operator.aggregation.AbstractTestApproximateCountDistinct.java

@Test(dataProvider = "provideStandardErrors")
public void testMultiplePositions(double maxStandardError) {
    DescriptiveStatistics stats = new DescriptiveStatistics();

    for (int i = 0; i < 500; ++i) {
        int uniques = ThreadLocalRandom.current().nextInt(getUniqueValuesCount()) + 1;

        List<Object> values = createRandomSample(uniques, (int) (uniques * 1.5));

        long actual = estimateGroupByCount(values, maxStandardError);
        double error = (actual - uniques) * 1.0 / uniques;

        stats.addValue(error);/* www.  ja  va2s.  c o  m*/
    }

    assertLessThan(stats.getMean(), 1.0e-2);
    assertLessThan(stats.getStandardDeviation(), 1.0e-2 + maxStandardError);
}

From source file:edu.nyu.vida.data_polygamy.standard_techniques.CorrelationTechniquesReducer.java

private double[] normalize(double[] array) {
    DescriptiveStatistics stats = new DescriptiveStatistics(array);
    double mean = stats.getMean();
    double stdDev = stats.getStandardDeviation();
    for (int i = 0; i < array.length; i++) {
        array[i] = (array[i] - mean) / stdDev;
    }/*from w  ww .  j  a  v a  2  s .co m*/
    return array;
}

From source file:algorithms.quality.ColorDivergenceVariance.java

@Override
public double getQuality(Colormap colormap) {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    Iterator<Point2D> ptIt = strategy.getPoints().iterator();

    while (ptIt.hasNext()) {
        Point2D p1 = ptIt.next();

        if (!ptIt.hasNext())
            break;

        Point2D p2 = ptIt.next();

        double dist = p1.distance(p2);

        Color colorA = colormap.getColor(p1.getX(), p1.getY());
        Color colorB = colormap.getColor(p2.getX(), p2.getY());

        // roughly 0-100
        double cdist = MedianDivergenceComputer.colorDiff(colorA, colorB);

        double ratio = cdist / dist;

        stats.addValue(ratio);//ww  w.  ja  v a2  s  .c  o m
    }

    return stats.getStandardDeviation();
}

From source file:com.caseystella.analytics.outlier.batch.rpca.RPCAOutlierAlgorithm.java

public double outlierScore(List<DataPoint> dataPoints, DataPoint value) {
    double[] inputData = new double[dataPoints.size() + 1];
    int numNonZero = 0;
    if (scaling != ScalingFunctions.NONE) {
        int i = 0;
        final DescriptiveStatistics stats = new DescriptiveStatistics();
        for (DataPoint dp : dataPoints) {
            inputData[i++] = dp.getValue();

            stats.addValue(dp.getValue());
            numNonZero += dp.getValue() > EPSILON ? 1 : 0;
        }//from w w w .  j a v a  2 s  .  c o m
        inputData[i] = value.getValue();
        GlobalStatistics globalStats = new GlobalStatistics() {
            {
                setMax(stats.getMax());
                setMin(stats.getMin());
                setMax(stats.getMean());
                setStddev(stats.getStandardDeviation());
            }
        };
        for (i = 0; i < inputData.length; ++i) {
            inputData[i] = scaling.scale(inputData[i], globalStats);
        }
    } else {
        int i = 0;
        for (DataPoint dp : dataPoints) {
            inputData[i++] = dp.getValue();
            numNonZero += dp.getValue() > EPSILON ? 1 : 0;
        }
        inputData[i] = value.getValue();
    }
    int nCols = 1;
    int nRows = inputData.length;
    if (numNonZero > minRecords) {
        AugmentedDickeyFuller dickeyFullerTest = new AugmentedDickeyFuller(inputData);
        double[] inputArrayTransformed = inputData;
        if (!this.isForceDiff && dickeyFullerTest.isNeedsDiff()) {
            // Auto Diff
            inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff();
        } else if (this.isForceDiff) {
            // Force Diff
            inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff();
        }

        if (this.spenalty == null) {
            this.lpenalty = this.LPENALTY_DEFAULT;
            this.spenalty = this.SPENALTY_DEFAULT / Math.sqrt(Math.max(nCols, nRows));
        }

        // Calc Mean
        double mean = 0;
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            mean += inputArrayTransformed[n];
        }
        mean /= inputArrayTransformed.length;

        // Calc STDEV
        double stdev = 0;
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            stdev += Math.pow(inputArrayTransformed[n] - mean, 2);
        }
        stdev = Math.sqrt(stdev / (inputArrayTransformed.length - 1));

        // Transformation: Zero Mean, Unit Variance
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            inputArrayTransformed[n] = (inputArrayTransformed[n] - mean) / stdev;
        }

        // Read Input Data into Array
        // Read Input Data into Array
        double[][] input2DArray = new double[nRows][nCols];
        input2DArray = VectorToMatrix(inputArrayTransformed, nRows, nCols);

        RPCA rSVD = new RPCA(input2DArray, this.lpenalty, this.spenalty);

        double[][] outputE = rSVD.getE().getData();
        double[][] outputS = rSVD.getS().getData();
        double[][] outputL = rSVD.getL().getData();
        return outputS[nRows - 1][0];
    } else {
        return Double.NaN;
    }
}

From source file:mase.app.allocation.AllocationProblem.java

@Override
public EvaluationResult[] evaluateSolution(GroupController gc, long seed) {
    AgentController[] acs = gc.getAgentControllers(numAgents);
    RealMatrix distanceMatrix = new Array2DRowRealMatrix(numAgents, types.length);
    for (int i = 0; i < numAgents; i++) {
        AllocationAgent aa = (AllocationAgent) acs[i];
        for (int j = 0; j < types.length; j++) {
            distanceMatrix.setEntry(i, j, DIST.compute(aa.getLocation(), types[j]));
        }/*  w w  w  .java 2  s  .co m*/
    }

    DescriptiveStatistics pd = pairDistances(distanceMatrix);

    // fitness
    FitnessResult fr = new FitnessResult(1 - pd.getMean() / FastMath.sqrt(dimensions));

    // individual characterisation -- distance to each type
    List<EvaluationResult> vbrs = new ArrayList<>();
    for (double[] dists : distanceMatrix.getData()) {
        vbrs.add(new VectorBehaviourResult(dists));
    }
    CompoundEvaluationResult ser = new CompoundEvaluationResult(vbrs);

    // aux characterisation -- min, mean, max, sd pair distances
    VectorBehaviourResult aux = new VectorBehaviourResult(pd.getMin(), pd.getMean(), pd.getMax(),
            pd.getStandardDeviation());

    return new EvaluationResult[] { fr, aux, ser };
}

From source file:classifiers.ComplexClassifier.java

/**
 *
 * @throws Exception/*w w w .j  ava 2  s . c  om*/
 */
@Override
public void BewertunginProzent() throws Exception {

    double count = 0;
    double[][] bestergeb = new double[1][2];

    double[][] hilf;
    double[][] hilf2;
    for (int i = 0; i < anzahldurchlauf; i++) {
        Bootstrap(Modelmenge);
        train(this.traindaten);

        hilf = new double[1][2];
        hilf2 = new double[1][2];

        hilf = test(traindaten);

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

        hilf2 = test(testdaten);

        this.testergebnisse[0][0] = hilf2[0][0];
        this.testergebnisse[0][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:");
        //System.out.println("Validierungsngsdaten:");

        //  System.out.println("Fehlerquote Validierungs:" + " " + (double) (int) (this.testergebnisse[0][0] * 100) / 100 + "%" + "  " + "Dauer:" + " " + (int) (this.testergebnisse[0][1]) + "ms");
        // System.out.println("----------------------------------------------------------------------------------------");
    }
    DescriptiveStatistics stats1 = new DescriptiveStatistics();
    DescriptiveStatistics stat1 = new DescriptiveStatistics();
    for (int i = 0; i < trainergebnisse.length; i++) {
        stats1.addValue(trainergebnisse[0][0]);
        stat1.addValue(trainergebnisse[0][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[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)));

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

}

From source file:main.java.metric.Metric.java

public static void getServerStatistic(Cluster cluster) {
    DescriptiveStatistics _data = new DescriptiveStatistics();
    DescriptiveStatistics _inflow = new DescriptiveStatistics();
    DescriptiveStatistics _outflow = new DescriptiveStatistics();
    DescriptiveStatistics _meDMV = new DescriptiveStatistics();

    for (Server server : cluster.getServers()) {
        _data.addValue(server.getServer_total_data());
        _inflow.addValue(server.getServer_inflow());
        _outflow.addValue(server.getServer_outflow());
    }//w  w  w  .j a  v  a2s .c  om

    // New - mutually exclusive server sets
    ArrayList<Integer> estimated_dmgr = new ArrayList<Integer>();
    for (Entry<Pair<Integer, Integer>, Integer> entry : mutually_exclusive_serverSets.entrySet()) {
        _meDMV.addValue(entry.getValue());
        estimated_dmgr.add(entry.getValue());
    }

    // Sort the list containing data migration counts within individual server pairs
    Collections.sort(estimated_dmgr);

    // Sum up every floor(S/2) index values to get the estimated data migration time
    int estimated_mgr = 0;
    int j = 0;
    for (int i = 0; i < estimated_dmgr.size(); ++i) {
        j = (int) (i + Math.floor(Global.servers / 2));
        estimated_mgr += estimated_dmgr.get(i);
        i = j;
    }

    mean_server_inflow.add(_inflow.getMean());
    mean_server_outflow.add(_outflow.getMean());
    mean_server_data.add(_data.getMean());
    sd_server_data.add(_data.getStandardDeviation());
    total_data.add((long) Global.global_dataCount);

    mean_pairwise_inter_server_data_mgr.add(_meDMV.getMean());
    sd_pairwise_inter_server_data_mgr.add(_meDMV.getStandardDeviation());
    estimated_data_mgr.add(estimated_mgr);
}

From source file:com.intuit.tank.persistence.databases.BucketDataItemTest.java

/**
 * Run the DescriptiveStatistics getStats() method test.
 * //from w  w w  .j a v  a  2 s . c om
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/10/14 10:32 AM
 */
@Test
public void testGetStats_1() throws Exception {
    BucketDataItem fixture = new BucketDataItem(1, new Date(), new DescriptiveStatistics());

    DescriptiveStatistics result = fixture.getStats();

    assertNotNull(result);
    assertEquals(
            "DescriptiveStatistics:\nn: 0\nmin: NaN\nmax: NaN\nmean: NaN\nstd dev: NaN\nmedian: NaN\nskewness: NaN\nkurtosis: NaN\n",
            result.toString());
    assertEquals(Double.NaN, result.getMax(), 1.0);
    assertEquals(Double.NaN, result.getVariance(), 1.0);
    assertEquals(Double.NaN, result.getMean(), 1.0);
    assertEquals(-1, result.getWindowSize());
    assertEquals(0.0, result.getSumsq(), 1.0);
    assertEquals(Double.NaN, result.getKurtosis(), 1.0);
    assertEquals(0.0, result.getSum(), 1.0);
    assertEquals(Double.NaN, result.getSkewness(), 1.0);
    assertEquals(Double.NaN, result.getPopulationVariance(), 1.0);
    assertEquals(Double.NaN, result.getStandardDeviation(), 1.0);
    assertEquals(Double.NaN, result.getGeometricMean(), 1.0);
    assertEquals(0L, result.getN());
    assertEquals(Double.NaN, result.getMin(), 1.0);
}

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  w w .ja  va  2 s.c  o m
        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;
            
     }*/
}