use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.
the class TestMeasurementSimulator method testSampleToSampleError.
/**
* Turn on sample-to-sample error, turn off all other sources of error,
* simulate 1 dish of data with 1000 samples per dish, and look to see
* whether in the aggregated data the standard deviations of Gene2:t1 and
* Gene3:t1 are 0.2.
*/
public void testSampleToSampleError() {
setDefaultParameters();
// The following parameters are set to non-default values for
// this test.
this.simulator.setNumSamplesPerDish(1000);
this.simulator.setSampleSampleVariability(0.2);
this.simulator.setChipChipVariability(0.0001);
this.simulator.setPixelDigitalization(0.0001);
this.simulator.setStepsGenerated(2);
this.simulator.setNumCellsPerDish(100);
// Simulate the data.
this.simulator.simulate(this.history);
double[][][] measuredData = this.simulator.getMeasuredData();
// Do the test.
DoubleArrayList doubleArrayList = new DoubleArrayList(measuredData[1][0]);
double sum = Descriptive.sum(doubleArrayList);
double sumOfSquares = Descriptive.sumOfSquares(doubleArrayList);
double gene2time1sd = Descriptive.standardDeviation(Descriptive.variance(measuredData[1][0].length, sum, sumOfSquares));
DoubleArrayList doubleArrayList1 = new DoubleArrayList(measuredData[2][0]);
double sum1 = Descriptive.sum(doubleArrayList1);
double sumOfSquares1 = Descriptive.sumOfSquares(doubleArrayList1);
double gene3time1sd = Descriptive.standardDeviation(Descriptive.variance(measuredData[2][0].length, sum1, sumOfSquares1));
assertEquals(0.2, gene2time1sd, 0.02);
assertEquals(0.2, gene3time1sd, 0.02);
}
use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.
the class TestMeasurementSimulator method testDishToDishVariability.
/**
* Turn on dish-to-dish variability error, turn off all other sources of
* error, simulate 100 dishes of data with 1 sample per dish, and look to
* see whether in the aggregated data Gene2:t1 and Gene3:t1 have standard
* deviations that are 10% of their respective means.
*/
public void testDishToDishVariability() {
setDefaultParameters();
// The following parameters are set to non-default values for
// this test.
this.simulator.setNumDishes(100);
this.simulator.setStepsGenerated(2);
this.simulator.setNumSamplesPerDish(1);
this.simulator.setSampleSampleVariability(0.0001);
this.simulator.setChipChipVariability(0.0001);
this.simulator.setPixelDigitalization(0.0001);
this.simulator.setNumCellsPerDish(100);
// Simulate the data.
this.simulator.simulate(this.history);
double[][][] measuredData = this.simulator.getMeasuredData();
// Do the test.
DoubleArrayList doubleArrayList = new DoubleArrayList(measuredData[1][0]);
double sum = Descriptive.sum(doubleArrayList);
double sumOfSquares = Descriptive.sumOfSquares(doubleArrayList);
double gene2time1sd = Descriptive.standardDeviation(Descriptive.variance(measuredData[1][0].length, sum, sumOfSquares));
DoubleArrayList doubleArrayList1 = new DoubleArrayList(measuredData[2][0]);
double sum1 = Descriptive.sum(doubleArrayList1);
double sumOfSquares1 = Descriptive.sumOfSquares(doubleArrayList1);
double gene3time1sd = Descriptive.standardDeviation(Descriptive.variance(measuredData[2][0].length, sum1, sumOfSquares1));
double gene2time1mean = Descriptive.mean(new DoubleArrayList(measuredData[1][0]));
double gene3time1mean = Descriptive.mean(new DoubleArrayList(measuredData[2][0]));
assertEquals(Math.abs(0.1 * gene2time1mean), gene2time1sd, 0.03);
assertEquals(Math.abs(0.1 * gene3time1mean), gene3time1sd, 0.03);
}
use of cern.colt.list.DoubleArrayList in project beast2 by CompEvol.
the class KernelDensityEstimator2D method bandwidthNRD.
// bandwidth.nrd =
// function (x)
// {
// r <- quantile(x, c(0.25, 0.75))
// h <- (r[2] - r[1])/1.34
// 4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5)
// }
public double bandwidthNRD(double[] in) {
DoubleArrayList inList = new DoubleArrayList(in.length);
for (double d : in) inList.add(d);
inList.sort();
final double h = (Descriptive.quantile(inList, 0.75) - Descriptive.quantile(inList, 0.25)) / 1.34;
return 4 * 1.06 * Math.min(Math.sqrt(DiscreteStatistics.variance(in)), h) * Math.pow(in.length, -0.2);
}
use of cern.colt.list.DoubleArrayList in project tdq-studio-se by Talend.
the class QuantileFinderTest method observedEpsilonsAtPhis.
/**
* This method was created in VisualAge.
* @return double[]
* @param values cern.it.hepodbms.primitivearray.DoubleArrayList
* @param phis double[]
*/
public static DoubleArrayList observedEpsilonsAtPhis(DoubleArrayList phis, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder, double desiredEpsilon) {
DoubleArrayList epsilons = new DoubleArrayList(phis.size());
for (int i = phis.size(); --i >= 0; ) {
double epsilon = observedEpsilonAtPhi(phis.get(i), exactFinder, approxFinder);
epsilons.add(epsilon);
if (epsilon > desiredEpsilon)
System.out.println("Real epsilon = " + epsilon + " is larger than desired by " + (epsilon - desiredEpsilon));
}
return epsilons;
}
use of cern.colt.list.DoubleArrayList in project tdq-studio-se by Talend.
the class Descriptive method quantiles.
/**
* Returns the quantiles of the specified percentages.
* The quantiles need not necessarily be contained in the data sequence, it can be a linear interpolation.
* @param sortedData the data sequence; <b>must be sorted ascending</b>.
* @param percentages the percentages for which quantiles are to be computed.
* Each percentage must be in the interval <tt>[0.0,1.0]</tt>.
* @return the quantiles.
*/
public static DoubleArrayList quantiles(DoubleArrayList sortedData, DoubleArrayList percentages) {
int s = percentages.size();
DoubleArrayList quantiles = new DoubleArrayList(s);
for (int i = 0; i < s; i++) {
quantiles.add(quantile(sortedData, percentages.get(i)));
}
return quantiles;
}
Aggregations