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

/**
 * Tests well calculation./*w  ww  . j a  v a  2  s. c o m*/
 */
@Test
public void testWell() {

    for (Plate plate : array) {

        for (Well well : plate) {

            int inputPercentile = 1 + random.nextInt(100);
            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.getPercentile(inputPercentile);

            BigDecimal returned = percentile.well(well, inputPercentile);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation using indices.
 *///  w  w w. j  av  a  2  s .  com
@Test
public void testWellIndices() {

    for (Plate plate : arrayIndices) {

        for (Well well : plate) {

            int inputPercentile = 1 + random.nextInt(100);

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

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

            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 resultDouble = stat.getPercentile(inputPercentile);

            BigDecimal returned = percentile.well(well, begin, end - begin, inputPercentile);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation.//from  www .ja  v  a2s .  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 (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getVariance();
            resultDouble *= well.size() - 1;
            resultDouble /= well.size();

            BigDecimal returned = variance.well(well, mc);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation.//w  ww. j  a  v a 2  s  . c o m
 */
@Test
public void testWell() {

    for (PlateBigInteger plate : array) {

        for (WellBigInteger well : plate) {

            int inputPercentile = 1 + random.nextInt(100);
            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.getPercentile(inputPercentile);

            BigDecimal returned = percentile.well(well, inputPercentile);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation.// w ww  .  j a  v  a2  s . c om
 */
@Test
public void testWell() {

    for (PlateBigInteger plate : array) {

        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.getVariance();
            resultDouble *= well.size() - 1;
            resultDouble /= well.size();

            BigDecimal returned = variance.well(well, mc);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation using indices.
 *//*from w w w.  ja v  a  2 s . c om*/
@Test
public void testWellIndices() {

    for (PlateBigInteger plate : arrayIndices) {

        for (WellBigInteger well : plate) {

            int inputPercentile = 1 + random.nextInt(100);

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

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

            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 resultDouble = stat.getPercentile(inputPercentile);

            BigDecimal returned = percentile.well(well, begin, end - begin, inputPercentile);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation using indices.
 *///from   ww  w. ja  v a  2  s.  c om
@Test
public void testWellIndices() {

    for (Plate plate : arrayIndices) {

        for (Well well : plate) {

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

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

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

            double[] inputArray = ArrayUtils.subarray(input, begin, end);

            DescriptiveStatistics stat = new DescriptiveStatistics(inputArray);
            double resultDouble = stat.getVariance();
            resultDouble *= inputArray.length - 1;
            resultDouble /= inputArray.length;

            BigDecimal returned = variance.well(well, begin, end - begin, mc);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

/**
 * Tests well calculation using indices.
 *//*from   w ww. ja v a2  s. co  m*/
@Test
public void testWellIndices() {

    for (PlateBigInteger plate : arrayIndices) {

        for (WellBigInteger well : plate) {

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

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

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

            double[] inputArray = ArrayUtils.subarray(input, begin, end);

            DescriptiveStatistics stat = new DescriptiveStatistics(inputArray);
            double resultDouble = stat.getVariance();
            resultDouble *= inputArray.length - 1;
            resultDouble /= inputArray.length;

            BigDecimal returned = variance.well(well, begin, end - begin, mc);
            BigDecimal result = new BigDecimal(resultDouble);

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

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

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

    for (Plate plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

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

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

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

/**
 * Tests set calculation./*from   ww w.  ja  va  2s.  com*/
 */
@Test
public void testSet() {

    int inputPercentile = 1 + random.nextInt(100);

    for (Plate plate : array) {

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

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

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

}