Search in sources :

Example 61 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project tdq-studio-se by Talend.

the class QuantileBin1D method splitApproximately.

/**
 *Divides (rebins) a copy of the receiver at the given <i>interval boundaries</i> into bins and returns these bins, such that each bin <i>approximately</i> reflects the data elements of its range.
 *
 *For each interval boundary of the axis (including -infinity and +infinity), computes the percentage (quantile inverse) of elements less than the boundary.
 *Then lets {@link #splitApproximately(DoubleArrayList,int)} do the real work.
 *
 *@param axis an axis defining interval boundaries.
 *@param resolution a measure of accuracy; the desired number of subintervals per interval.
 */
public synchronized MightyStaticBin1D[] splitApproximately(hep.aida.IAxis axis, int k) {
    DoubleArrayList percentages = new DoubleArrayList(new hep.aida.ref.Converter().edges(axis));
    percentages.beforeInsert(0, Double.NEGATIVE_INFINITY);
    percentages.add(Double.POSITIVE_INFINITY);
    for (int i = percentages.size(); --i >= 0; ) {
        percentages.set(i, quantileInverse(percentages.get(i)));
    }
    return splitApproximately(percentages, k);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 62 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.

the class StatUtils method expScore.

public static double expScore(double[] _f) {
    // _f = DataUtils.standardizeData(_f);
    DoubleArrayList f = new DoubleArrayList(_f);
    for (int k = 0; k < _f.length; k++) {
        f.set(k, Math.exp(f.get(k)));
    }
    double expected = Descriptive.mean(f);
    return Math.log(expected);
// double diff = logExpected - 0.5;
// return Math.abs(diff);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 63 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.

the class StatUtils method logCoshScore.

public static double logCoshScore(double[] _f) {
    _f = standardizeData(_f);
    DoubleArrayList f = new DoubleArrayList(_f);
    for (int k = 0; k < _f.length; k++) {
        double v = Math.log(Math.cosh((f.get(k))));
        f.set(k, v);
    }
    double expected = Descriptive.mean(f);
    double diff = expected - logCoshExp;
    return diff * diff;
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 64 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.

the class TestMeasurementSimulator method testChipToChipError.

/**
 * Turn on chip to chip 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 for Gene2:t1, Gene3:t1, and
 * Gene1:t2 are 0.3.
 */
public void testChipToChipError() {
    setDefaultParameters();
    // The following parameters are set to non-default values for
    // this test.
    this.simulator.setDishDishVariability(0.0001);
    this.simulator.setNumSamplesPerDish(1000);
    this.simulator.setSampleSampleVariability(0.0001);
    this.simulator.setChipChipVariability(0.3);
    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));
    DoubleArrayList doubleArrayList2 = new DoubleArrayList(measuredData[1][1]);
    double sum2 = Descriptive.sum(doubleArrayList2);
    double sumOfSquares2 = Descriptive.sumOfSquares(doubleArrayList2);
    double gene1time2sd = Descriptive.standardDeviation(Descriptive.variance(measuredData[1][1].length, sum2, sumOfSquares2));
    assertEquals(0.3, gene2time1sd, 0.02);
    assertEquals(0.3, gene3time1sd, 0.02);
    assertEquals(0.3, gene1time2sd, 0.02);
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 65 with DoubleArrayList

use of cern.colt.list.DoubleArrayList in project tetrad by cmu-phil.

the class TestMeasurementSimulator method testTranscriptionError.

/**
 * Save out the raw data using default parameters and make sure that
 * Gene1:t2 has the specified standard deviation. Should be 0.05. (Gene1 has
 * only itself as parent.)
 */
public void testTranscriptionError() {
    // Raw data is saved for this simulation.
    setDefaultParameters();
    this.simulator.setRawDataSaved(true);
    this.simulator.setMeasuredDataSaved(false);
    // Simulate the data.
    this.simulator.simulate(this.history);
    double[][][] rawData = this.simulator.getRawData();
    // (Test the dimensions.)
    // # variables.
    assertEquals(3, rawData.length);
    // # time steps.
    assertEquals(4, rawData[0].length);
    // # cells / dish
    assertEquals(10000, rawData[0][0].length);
    // The test is to see whether Gene 1 at time step 2 has a
    // standard deviation of 0.05. Of course the gene and time
    // step numbers need to be 0-indexed.
    DoubleArrayList doubleArrayList = new DoubleArrayList(rawData[0][1]);
    double sum = Descriptive.sum(doubleArrayList);
    double sumOfSquares = Descriptive.sumOfSquares(doubleArrayList);
    double stdev = Descriptive.standardDeviation(Descriptive.variance(rawData[0][1].length, sum, sumOfSquares));
    assertEquals(0.05, stdev, 0.01);
}
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