Search in sources :

Example 1 with DoubleArrayList

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);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 2 with DoubleArrayList

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);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 3 with DoubleArrayList

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);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 4 with DoubleArrayList

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;
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 5 with DoubleArrayList

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;
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Aggregations

DoubleArrayList (cern.colt.list.DoubleArrayList)82 RegressionResult (edu.cmu.tetrad.regression.RegressionResult)11 ArrayList (java.util.ArrayList)9 AndersonDarlingTest (edu.cmu.tetrad.data.AndersonDarlingTest)8 IntArrayList (cern.colt.list.IntArrayList)6 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)5 TetradVector (edu.cmu.tetrad.util.TetradVector)5 Test (org.junit.Test)5 DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)4 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)4 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)3 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)3 Regression (edu.cmu.tetrad.regression.Regression)3 RegressionDataset (edu.cmu.tetrad.regression.RegressionDataset)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)2 Record (org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record)2 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)2 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)2 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)2