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.microflexbiginteger.stat.SumTest.java

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

    for (Plate 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<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = sum.plate(plate, begin, end - begin, mc);

        for (Well well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double resultDouble = stat.getSum();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

/**
 * Tests the plate statistics method using the values between the indices.
 *///w  w  w  . ja  v a2s.c  o  m
@Test
public void testPlateIndices() {

    for (PlateDouble plate : arrayIndices) {

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

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

        for (WellDouble 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.getMean();

            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.microflexbigdecimal.stat.KurtosisTest.java

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

    for (Plate 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<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = kurtosis.plate(plate, begin, end - begin, mc);

        for (Well well : plate) {

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

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double resultDouble = stat.getKurtosis();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

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

    for (Plate 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<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = skewness.plate(plate, begin, end - begin, mc);

        for (Well well : plate) {

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

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double resultDouble = stat.getSkewness();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

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

    for (PlateInteger plate : arrayIndices) {

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

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

        for (WellInteger 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.getSum();

            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.microflexbigdecimal.stat.SumOfSquaresTest.java

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

    for (Plate 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<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = sum.plate(plate, begin, end - begin, mc);

        for (Well well : plate) {

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

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

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

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

/**
 * Tests the plate statistics method using the values between the indices.
 *///from   w ww  .jav  a2s.com
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

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

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = mean.plate(plate, begin, end - begin, mc);

        for (Well well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

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

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

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

/**
 * Tests the plate statistics method using the values between the indices.
 *//* w  w  w. jav  a2s. c  o  m*/
@Test
public void testPlateIndices() {

    for (PlateInteger plate : arrayIndices) {

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

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

        for (WellInteger 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.getMean();

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

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

    for (PlateDouble plate : arrayIndices) {

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

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

        for (WellDouble 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 (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.microflexbigdecimal.stat.NTest.java

/**
 * Tests the aggregated plate statistics method using a collection.
 *///from   ww  w  .  j  a  v a2s .  c  o 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 (BigDecimal bd : well) {
                resultList.add(bd.doubleValue());
            }

        }

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