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

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

Introduction

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

Prototype

public double getVariance() 

Source Link

Document

Returns the (sample) variance of the available values.

Usage

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

/**
 * Tests the plate statistics method.//w  ww  . java  2  s . co m
 */
@Test
public void testPlate() {

    for (PlateInteger plate : array) {

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

        for (WellInteger well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceWeightsTest.java

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

    for (Plate plate : array) {

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

        for (Well well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceDoubleWeightsTest.java

/**
 * Tests the plate statistics method./*  w ww .  j  ava2s.co  m*/
 */
@Test
public void testPlate() {

    for (PlateDouble plate : array) {

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

        for (WellDouble well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceIntegerWeightsTest.java

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

    for (PlateInteger plate : array) {

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

        for (WellInteger well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceWeightsTest.java

/**
 * Tests set calculation./*  w w  w .  ja  v  a2  s.  c  o  m*/
 */
@Test
public void testSet() {

    for (Plate plate : array) {

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

        for (Well well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceDoubleWeightsTest.java

/**
 * Tests set calculation./*www  .j a  v  a2s. com*/
 */
@Test
public void testSet() {

    for (PlateDouble plate : array) {

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

        for (WellDouble well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

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

            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.SampleVarianceIntegerWeightsTest.java

/**
 * Tests well calculation.// www  . j a v  a2s  .c  o  m
 */
@Test
public void testWell() {

    for (PlateInteger plate : array) {

        for (WellInteger well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);

            double result = Precision.round(stat.getVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}

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

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

    for (Plate plate : array) {

        for (Well well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);

            double result = Precision.round(stat.getVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation./*w  w  w  .j a va 2s  .com*/
 */
@Test
public void testWell() {

    for (PlateDouble plate : array) {

        for (WellDouble well : plate) {

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

            for (double db : well) {
                input[index] = db * weights[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);

            double result = Precision.round(stat.getVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation.//w ww  . j a  v a  2  s .c o m
 */
@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.getVariance();

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

            BigDecimal[] corrected = correctRoundingErrors(returned, result);
            assertEquals(corrected[0], corrected[1]);
        }
    }
}