Example usage for java.math BigInteger doubleValue

List of usage examples for java.math BigInteger doubleValue

Introduction

In this page you can find the example usage for java.math BigInteger doubleValue.

Prototype

public double doubleValue() 

Source Link

Document

Converts this BigInteger to a double .

Usage

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

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

    for (Plate plate : arrayIndices) {

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = mean.platesAggregated(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.getMean();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

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

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

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

    for (Plate plate : arrayIndices) {

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = mean.setsAggregated(plate.dataSet(), 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.getMean();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.MeanBigIntegerTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*from  ww  w.ja va 2 s .  c  o  m*/
@Test
public void testAggregatedPlateIndices() {

    for (PlateBigInteger plate : arrayIndices) {

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = mean.platesAggregated(plate, begin, end - begin, mc);

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.MeanBigIntegerTest.java

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

    for (PlateBigInteger plate : arrayIndices) {

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = mean.setsAggregated(plate.dataSet(), begin, end - begin, mc);

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

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

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

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

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

    for (Plate plate : collection) {

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

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : collection) {

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

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

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

/**
 * Tests the aggregated plate statistics method using an array.
 *//*from   w  w w. j  ava 2 s.  c o  m*/
@Test
public void testAggregatedPlateArray() {

    Map<Plate, BigDecimal> aggregatedReturnedMap = mean.platesAggregated(array, mc);
    Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>();

    for (Plate plate : array) {

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

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : array) {

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

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

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

}

From source file:com.github.jessemull.microflex.stat.statbiginteger.MeanBigIntegerTest.java

/**
 * Tests the aggregated plate statistics method using a collection.
 *///from www  .j  a  v a  2  s. c o m
@Test
public void testAggregatedPlateCollection() {

    List<PlateBigInteger> collection = Arrays.asList(array);
    Map<PlateBigInteger, BigDecimal> aggregatedReturnedMap = mean.platesAggregated(collection, mc);
    Map<PlateBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<PlateBigInteger, BigDecimal>();

    for (PlateBigInteger plate : collection) {

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

        for (WellBigInteger well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getMean();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateBigInteger plate : collection) {

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

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

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

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the array./*from   w  ww .  j av  a  2  s.c  om*/
 */
@Test
public void testAggregatedPlateArrayIndices() {

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

    Map<Plate, BigDecimal> aggregatedReturnedMap = mean.platesAggregated(arrayIndices, begin, end - begin, mc);
    Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>();

    for (Plate plate : arrayIndices) {

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

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : arrayIndices) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.MeanBigIntegerTest.java

/**
 * Tests the aggregated plate statistics method using an array.
 *//*from   w  w  w  . j a  v  a2 s.  c o  m*/
@Test
public void testAggregatedPlateArray() {

    Map<PlateBigInteger, BigDecimal> aggregatedReturnedMap = mean.platesAggregated(array, mc);
    Map<PlateBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<PlateBigInteger, BigDecimal>();

    for (PlateBigInteger plate : array) {

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

        for (WellBigInteger well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getMean();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateBigInteger plate : array) {

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

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

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

}

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

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection.//from   w  w w  . java2  s. c  om
 */
@Test
public void testAggregatedPlateCollectionIndices() {

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

    List<Plate> collection = Arrays.asList(arrayIndices);
    Map<Plate, BigDecimal> aggregatedReturnedMap = mean.platesAggregated(collection, begin, end - begin, mc);

    Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>();

    for (Plate plate : collection) {

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

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultList.add(result);
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);
        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : collection) {

        BigDecimal result = aggregatedResultMap.get(plate);
        BigDecimal returned = aggregatedReturnedMap.get(plate);
        BigDecimal[] corrected = correctRoundingErrors(result, returned);

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