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

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

Introduction

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

Prototype

public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException 

Source Link

Document

Copy constructor.

Usage

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

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

    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);

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

        for (WellInteger well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.SumOfSquaresWeightsTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///  w  w w  .ja v a  2s .c om
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

        int begin = random.nextInt(plate.first().size() - 4);
        int end = begin + random.nextInt(3) + 3;

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin,
                end - begin);

        for (Well well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getSumsq();

            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.microflexdouble.stat.NTest.java

/**
 * Tests the aggregated plate statistics method using a collection.
 */// ww w  .java  2s . co m
@Test
public void testAggregatedPlateCollection() {

    List<Plate> collection = Arrays.asList(array);
    Map<Plate, Integer> aggregatedReturnedMap = n.platesAggregated(collection);
    Map<Plate, Integer> aggregatedResultMap = new TreeMap<Plate, Integer>();

    for (Plate plate : collection) {

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

        for (Well well : plate) {

            for (double db : well) {
                resultList.add(db);
            }

        }

        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 = statAggregated.getN();

        aggregatedResultMap.put(plate, (int) resultAggregated);
    }

    for (Plate plate : collection) {

        int result = aggregatedResultMap.get(plate);
        int returned = aggregatedReturnedMap.get(plate);

        assertEquals(result, returned);
    }
}

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

/**
 * Tests the plate statistics method using the values between the indices.
 *//*from  www .j  av a  2 s  . co  m*/
@Test
public void testPlateIndices() {

    for (PlateDouble plate : arrayIndices) {

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

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

        for (WellDouble well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.microflexdouble.stat.GeometricMeanWeightsTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *//*from   w  w w .j  a  va2 s .co m*/
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

        int begin = random.nextInt(plate.first().size() - 4);
        int end = begin + random.nextInt(3) + 3;

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = mean.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end),
                begin, end - begin);

        for (Well well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getGeometricMean();

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

/**
 * Tests the plate statistics method using the values between the indices.
 *//* w  w w.  j a  v  a2  s.co  m*/
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

        int begin = random.nextInt(plate.first().size() - 4);
        int end = begin + random.nextInt(3) + 3;

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end),
                begin, end - begin);

        for (Well well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.statinteger.PopulationVarianceIntegerTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///  ww w  . j a v a2s.c  om
@Test
public void testPlateIndices() {

    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);

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

        for (WellInteger well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.microflex.stat.statdouble.SampleStandardDeviationDoubleTest.java

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

    for (PlateDouble plate : arrayIndices) {

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

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = deviation.plate(plate, begin, end - begin);

        for (WellDouble well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getStandardDeviation();

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

/**
 * Tests the plate statistics method using the values between the indices.
 *//* w  w  w .  j  av  a2 s .  c om*/
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

        int begin = random.nextInt(plate.first().size() - 4);
        int end = begin + random.nextInt(3) + 3;

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end),
                begin, end - begin);

        for (Well well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.statinteger.StandardDeviationIntegerTest.java

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

    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);

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = deviation.plate(plate, begin, end - begin);

        for (WellInteger well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getStandardDeviation();

            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);
        }
    }
}