List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics
public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException
From source file:com.github.jessemull.microflexbiginteger.stat.NTest.java
/** * Tests the plate statistics method./*from w ww . j a va2 s. c o m*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Integer> resultMap = new TreeMap<Well, Integer>(); Map<Well, Integer> returnedMap = n.plate(plate); 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 result = stat.getN(); resultMap.put(well, (int) result); } for (Well well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:com.github.jessemull.microflex.stat.statinteger.NIntegerTest.java
/** * Tests the plate statistics method./*from w ww . j a v a 2 s . c om*/ */ @Test public void testPlate() { for (PlateInteger plate : array) { Map<WellInteger, Integer> resultMap = new TreeMap<WellInteger, Integer>(); Map<WellInteger, Integer> returnedMap = n.plate(plate); for (WellInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (double db : well) { input[index++] = db; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getN(); resultMap.put(well, (int) result); } for (WellInteger well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:io.realm.datastorebenchmark.DataStoreTest.java
public void saveMeasurements(String filePrefix) { String tag = getTag();/* w w w .j a v a 2 s .co m*/ try { // one file per test with raw data for (String key : keys) { File file1 = new File(Environment.getExternalStorageDirectory() + "/datastorebenchmark", tag + "_" + key + ".csv"); FileOutputStream fileOutputStream1 = new FileOutputStream(file1, false); List<Long> measurement = measurements.get(key); for (int i = 0; i < measurement.size(); i++) { fileOutputStream1.write(String.format("%d\n", measurement.get(i).longValue()).getBytes()); } fileOutputStream1.close(); } // combined CSV file File file = new File(Environment.getExternalStorageDirectory() + "/datastorebenchmark", filePrefix + ".csv"); FileOutputStream fileOutputStream = new FileOutputStream(file, true); fileOutputStream.write(String.format("%s;", tag).getBytes()); for (String key : keys) { List<Long> measurement = measurements.get(key); double[] doubles = new double[measurement.size()]; for (int i = 0; i < measurement.size(); i++) { doubles[i] = measurement.get(i).doubleValue(); } Collections.sort(measurement); DescriptiveStatistics results = new DescriptiveStatistics(doubles); fileOutputStream.write(String .format("%e;%e;%e;", results.getMin(), results.getMax(), results.getMean()).getBytes()); } fileOutputStream.write("\n".getBytes()); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.NBigDecimalTest.java
/** * Tests the plate statistics method.//from www .ja v a2 s .c om */ @Test public void testPlate() { for (PlateBigDecimal plate : array) { Map<WellBigDecimal, Integer> resultMap = new TreeMap<WellBigDecimal, Integer>(); Map<WellBigDecimal, Integer> returnedMap = n.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 result = stat.getN(); resultMap.put(well, (int) result); } for (WellBigDecimal well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java
/** * Tests the plate statistics method.//from ww w .ja v a 2 s.co m */ @Test public void testPlate() { for (PlateBigInteger plate : array) { Map<WellBigInteger, Integer> resultMap = new TreeMap<WellBigInteger, Integer>(); Map<WellBigInteger, Integer> returnedMap = n.plate(plate); 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 result = stat.getN(); resultMap.put(well, (int) result); } for (WellBigInteger well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:es.csic.iiia.planes.util.InverseWishartDistributionTest.java
private double testScale(double scale, double df) { RealMatrix scaleMatrix = new Array2DRowRealMatrix(new double[][] { { 1 / scale, 0 }, { 0, 1 / scale }, }); DescriptiveStatistics stats = new DescriptiveStatistics(WISHART_SAMPLES * NORMAL_SAMPLES); for (int i = 0; i < WISHART_SAMPLES; i++) { InverseWishartDistribution instance = new InverseWishartDistribution(scaleMatrix, df); stats.addValue(computeRadius(instance)); }/* w ww .ja v a 2 s.c om*/ return stats.getPercentile(50); }
From source file:com.github.jessemull.microflexdouble.stat.MaxTest.java
/** * Tests the plate statistics method./*from w w w . j a v a 2s . c om*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = max.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getMax(); 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.MinTest.java
/** * Tests the plate statistics method./*w w w . j a va 2 s . c o m*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = min.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getMin(); 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.SumTest.java
/** * Tests the plate statistics method.//from w w w . j a va 2 s . c o m */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = sum.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getSum(); 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.MeanTest.java
/** * Tests the plate statistics method./*from w w w . j av a 2 s. c om*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = mean.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getMean(); 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); } } }