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

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

Introduction

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

Prototype

public double getMax() 

Source Link

Document

Returns the maximum of the available values

Usage

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

/**
 * Tests well calculation./*from   www .  j  av  a  2  s.com*/
 */
@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.getMax();

            BigDecimal returned = max.well(well);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

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

/**
 * Tests the plate statistics method.//from  ww w. ja  va  2  s . com
 */
@Test
public void testPlate() {

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = max.plate(plate);

        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(input);
            double resultDouble = stat.getMax();

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

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

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = max.set(plate.dataSet());

        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(input);
            double resultDouble = stat.getMax();

            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.statbigdecimal.MaxBigDecimalTest.java

/**
 * Tests the plate statistics method.//  w  ww .ja v  a 2s  . com
 */
@Test
public void testPlate() {

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = max.plate(plate);

        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.getMax();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigDecimal 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.statbigdecimal.MaxBigDecimalTest.java

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

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = max.set(plate.dataSet());

        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.getMax();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigDecimal 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:knop.psfj.BeadAverager.java

/**
 * Average bead.//from w  w  w. j av a 2  s .  c  om
 *
 * @param frameList the frame list
 * @return the image plus
 */
public ImagePlus averageBead(ArrayList<BeadFrame> frameList) {

    ImagePlus result;
    DescriptiveStatistics centerX = new DescriptiveStatistics();
    DescriptiveStatistics centerY = new DescriptiveStatistics();
    DescriptiveStatistics centerZ = new DescriptiveStatistics();

    int originalStackSize = frameList.get(0).getSliceNumber();

    setTotalBeads(frameList.size());

    //frameList = filter(frameList);

    ArrayList<ImageStack> centeredStacks = new ArrayList<ImageStack>();

    for (BeadFrame frame : frameList) {

        System.out.println(frame.getCentroidXAsInt());
        centerX.addValue(frame.getCentroidXAsInt());
        centerY.addValue(frame.getCentroidYAsInt());
        centerZ.addValue(frame.getCentroidZAsInt());

    }

    int chosenCenter = MathUtils.round(centerZ.getPercentile(50));
    int maxUp = chosenCenter - MathUtils.round(chosenCenter - centerZ.getMin());
    int maxDown = originalStackSize - MathUtils.round(centerZ.getMax());

    System.out.println(maxUp);
    System.out.println(maxDown);

    for (BeadFrame frame : frameList) {
        ImageStack subStack = new ImageStack(frame.getSubstack().getWidth(), frame.getSubstack().getHeight());
        int center = frame.getCentroidZAsInt();
        int begin = center - maxUp;
        int end = center + maxDown;
        System.out.println(String.format(" Groing from %d to %d with a center at %d", begin, end, center));
        for (int i = begin; i != end; i++) {
            subStack.addSlice(frame.getSubstack().getImageStack().getProcessor(i + 1));
        }

        centeredStacks.add(subStack);
        //new ImagePlus("",subStack).show();

    }

    System.out.println(centerX);
    System.out.println(centerY);
    System.out.println(centerZ);

    return new ImagePlus("", averageStacks(centeredStacks));

}

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

/**
 * Tests the aggregated plate statistics method.
 *//*from   www.  j a  v  a  2 s  .co  m*/
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = max.platesAggregated(plate);

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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.getMax();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *//*from  ww w  . j av  a 2 s  .co m*/
@Test
public void testAggregatedSet() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = max.setsAggregated(plate.dataSet());

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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.getMax();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 */// ww  w  .j av a2 s  . c  om
@Test
public void testAggregatedPlate() {

    for (PlateBigDecimal plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = max.platesAggregated(plate);

        for (WellBigDecimal well : plate) {
            resultList.addAll(well.data());
        }

        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.getMax();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///from   w  ww  .  j av  a  2s  . co m
@Test
public void testAggregatedSet() {

    for (PlateBigDecimal plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = max.setsAggregated(plate.dataSet());

        for (WellBigDecimal well : plate) {
            resultList.addAll(well.data());
        }

        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.getMax();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}