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

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

Introduction

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

Prototype

public double getSumsq() 

Source Link

Document

Returns the sum of the squares of the available values.

Usage

From source file:com.github.jessemull.microflexbiginteger.stat.SumOfSquaresWeightsTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection./*from   ww  w  . j  av  a 2 s. c om*/
 */
@Test
public void testAggregatedSetCollectionIndices() {

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

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

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

    Map<WellSet, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(collection, weightsIndices, begin,
            end - begin, mc);
    Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>();

    for (WellSet set : collection) {

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

        for (Well well : set) {

            List<BigDecimal> input = well.toBigDecimal().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet set : collection) {

        BigDecimal result = aggregatedResultMap.get(set);
        BigDecimal returned = aggregatedReturnedMap.get(set);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.SumOfSquaresBigIntegerWeightsTest.java

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

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

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

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

    Map<WellSetBigInteger, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(setArrayIndices,
            weightsIndices, begin, end - begin, mc);
    Map<WellSetBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigInteger, BigDecimal>();

    for (WellSetBigInteger set : setArrayIndices) {

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

        for (WellBigInteger well : set) {

            List<BigDecimal> input = well.toBigDecimal().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetBigInteger plate : setArrayIndices) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.github.jessemull.microflexbiginteger.stat.SumOfSquaresWeightsTest.java

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

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

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

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

    Map<WellSet, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(setArrayIndices, weightsIndices, begin,
            end - begin, mc);
    Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>();

    for (WellSet set : setArrayIndices) {

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

        for (Well well : set) {

            List<BigDecimal> input = well.toBigDecimal().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet plate : setArrayIndices) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

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

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

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

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

    Map<WellSetBigDecimal, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(collection, weightsIndices,
            begin, end - begin, mc);
    Map<WellSetBigDecimal, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigDecimal, BigDecimal>();

    for (WellSetBigDecimal set : collection) {

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

        for (WellBigDecimal well : set) {

            List<BigDecimal> input = well.data().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetBigDecimal set : collection) {

        BigDecimal result = aggregatedResultMap.get(set);
        BigDecimal returned = aggregatedReturnedMap.get(set);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.github.jessemull.microflexbigdecimal.stat.SumOfSquaresWeightsTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection.//from  w w w  . j a  v a2 s. c  om
 */
@Test
public void testAggregatedSetCollectionIndices() {

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

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

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

    Map<WellSet, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(collection, weightsIndices, begin,
            end - begin, mc);
    Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>();

    for (WellSet set : collection) {

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

        for (Well well : set) {

            List<BigDecimal> input = well.data().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet set : collection) {

        BigDecimal result = aggregatedResultMap.get(set);
        BigDecimal returned = aggregatedReturnedMap.get(set);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

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

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

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

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

    Map<WellSetBigDecimal, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(setArrayIndices,
            weightsIndices, begin, end - begin, mc);
    Map<WellSetBigDecimal, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigDecimal, BigDecimal>();

    for (WellSetBigDecimal set : setArrayIndices) {

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

        for (WellBigDecimal well : set) {

            List<BigDecimal> input = well.data().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetBigDecimal plate : setArrayIndices) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.github.jessemull.microflexbigdecimal.stat.SumOfSquaresWeightsTest.java

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

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

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

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

    Map<WellSet, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(setArrayIndices, weightsIndices, begin,
            end - begin, mc);
    Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>();

    for (WellSet set : setArrayIndices) {

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

        for (Well well : set) {

            List<BigDecimal> input = well.data().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i])));
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregatedDouble = statAggregated.getSumsq();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet plate : setArrayIndices) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.fpuna.preproceso.PreprocesoTS.java

private static TrainingSetFeature calculoFeaturesMagnitud(List<Registro> muestras, String activity) {

    TrainingSetFeature Feature = new TrainingSetFeature();
    DescriptiveStatistics stats_m = new DescriptiveStatistics();

    double[] fft_m;
    double[] AR_4;

    muestras = Util.calcMagnitud(muestras);

    for (int i = 0; i < muestras.size(); i++) {
        stats_m.addValue(muestras.get(i).getM_1());
    }//from  www. java 2  s.c  om

    //********* FFT *********
    //fft_m = Util.transform(stats_m.getValues());
    fft_m = FFTMixedRadix.fftPowerSpectrum(stats_m.getValues());

    //******************* Calculos Magnitud *******************//
    //mean(s) - Arithmetic mean
    System.out.print(stats_m.getMean() + ",");
    Feature.setMeanX((float) stats_m.getMean());

    //std(s) - Standard deviation
    System.out.print(stats_m.getStandardDeviation() + ",");
    Feature.setStdX((float) stats_m.getStandardDeviation());

    //mad(s) - Median absolute deviation
    //
    //max(s) - Largest values in array
    System.out.print(stats_m.getMax() + ",");
    Feature.setMaxX((float) stats_m.getMax());

    //min(s) - Smallest value in array
    System.out.print(stats_m.getMin() + ",");
    Feature.setMinX((float) stats_m.getMin());

    //skewness(s) - Frequency signal Skewness
    System.out.print(stats_m.getSkewness() + ",");
    Feature.setSkewnessX((float) stats_m.getSkewness());

    //kurtosis(s) - Frequency signal Kurtosis
    System.out.print(stats_m.getKurtosis() + ",");
    Feature.setKurtosisX((float) stats_m.getKurtosis());

    //energy(s) - Average sum of the squares
    System.out.print(stats_m.getSumsq() / stats_m.getN() + ",");
    Feature.setEnergyX((float) (stats_m.getSumsq() / stats_m.getN()));

    //entropy(s) - Signal Entropy
    System.out.print(Util.calculateShannonEntropy(fft_m) + ",");
    Feature.setEntropyX(Util.calculateShannonEntropy(fft_m).floatValue());

    //iqr (s) Interquartile range
    System.out.print(stats_m.getPercentile(75) - stats_m.getPercentile(25) + ",");
    Feature.setIqrX((float) (stats_m.getPercentile(75) - stats_m.getPercentile(25)));

    try {
        //autoregression (s) -4th order Burg Autoregression coefficients
        AR_4 = AutoRegression.calculateARCoefficients(stats_m.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] + ",");
        Feature.setArX1((float) AR_4[0]);
        Feature.setArX2((float) AR_4[1]);
        Feature.setArX3((float) AR_4[2]);
        Feature.setArX4((float) 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_m, stats_m.getValues()) + ",");
    Feature.setMeanFreqx((float) Util.meanFreq(fft_m, stats_m.getValues()));

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

    return Feature;
}

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());
    }/*  ww  w .ja  v a2 s  . c o m*/

    //********* 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:org.apache.metron.common.math.stats.OnlineStatisticsProviderTest.java

public static void validateStatisticsProvider(StatisticsProvider statsProvider, SummaryStatistics summaryStats,
        DescriptiveStatistics stats) {
    //N//from  ww  w  . j  av a 2s  .co m
    Assert.assertEquals(statsProvider.getCount(), stats.getN());
    //sum
    Assert.assertEquals(statsProvider.getSum(), stats.getSum(), 1e-3);
    //sum of squares
    Assert.assertEquals(statsProvider.getSumSquares(), stats.getSumsq(), 1e-3);
    //sum of squares
    Assert.assertEquals(statsProvider.getSumLogs(), summaryStats.getSumOfLogs(), 1e-3);
    //Mean
    Assert.assertEquals(statsProvider.getMean(), stats.getMean(), 1e-3);
    //Quadratic Mean
    Assert.assertEquals(statsProvider.getQuadraticMean(), summaryStats.getQuadraticMean(), 1e-3);
    //SD
    Assert.assertEquals(statsProvider.getStandardDeviation(), stats.getStandardDeviation(), 1e-3);
    //Variance
    Assert.assertEquals(statsProvider.getVariance(), stats.getVariance(), 1e-3);
    //Min
    Assert.assertEquals(statsProvider.getMin(), stats.getMin(), 1e-3);
    //Max
    Assert.assertEquals(statsProvider.getMax(), stats.getMax(), 1e-3);

    //Kurtosis
    Assert.assertEquals(stats.getKurtosis(), statsProvider.getKurtosis(), 1e-3);

    //Skewness
    Assert.assertEquals(stats.getSkewness(), statsProvider.getSkewness(), 1e-3);
    for (double d = 10.0; d < 100.0; d += 10) {
        //This is a sketch, so we're a bit more forgiving here in our choice of \epsilon.
        Assert.assertEquals("Percentile mismatch for " + d + "th %ile", statsProvider.getPercentile(d),
                stats.getPercentile(d), 1e-2);
    }
}