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

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

Introduction

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

Prototype

public double getPopulationVariance() 

Source Link

Document

Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance"> population variance</a> of the available values.

Usage

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

/**
 * Tests well calculation using indices.
 *//*  w ww.j  a v a2  s . 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.getPopulationVariance(), precision);
            double returned = Precision.round(variance.well(well, begin, end - begin), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests the plate statistics method.//from   ww w.  ja v a2  s .c  o m
 */
@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.getPopulationVariance();

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

/**
 * Tests the plate statistics method./*from   w w w .jav a 2s.  com*/
 */
@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.getPopulationVariance();

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

/**
 * Tests the plate statistics method.//w  w  w . jav  a2  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.getPopulationVariance();

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

/**
 * Tests set calculation.//from   w  ww . jav  a  2  s .  c om
 */
@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.getPopulationVariance();

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

/**
 * Tests set calculation.//from w  ww  .  j  a  v  a2 s.c  om
 */
@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.getPopulationVariance();

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

/**
 * Tests set calculation.//from  w w w  .ja  v  a  2  s  .  co 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.getPopulationVariance();

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

/**
 * Tests well calculation./*from w  w w .ja  va2s  . c o  m*/
 */
@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.getPopulationVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation./*from   w w w  . j av a  2  s  .  co m*/
 */
@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.getPopulationVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}

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

/**
 * Tests well calculation.//w w  w.  ja v a2 s . 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.getPopulationVariance(), precision);
            double returned = Precision.round(variance.well(well, weights), precision);

            assertTrue(result == returned);
        }
    }
}