Search in sources :

Example 26 with IntArrayList

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

the class QuantileFinderTest method observedEpsilonAtPhi.

/**
 * This method was created in VisualAge.
 * @return double[]
 * @param values cern.it.hepodbms.primitivearray.DoubleArrayList
 * @param phis double[]
 */
public static double observedEpsilonAtPhi(double phi, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder) {
    int N = (int) exactFinder.size();
    int exactRank = (int) Utils.epsilonCeiling(phi * N) - 1;
    // System.out.println("exactRank="+exactRank);
    // just to ensure exactFinder is sorted
    exactFinder.quantileElements(new DoubleArrayList(new double[] { phi })).get(0);
    double approxElement = approxFinder.quantileElements(new DoubleArrayList(new double[] { phi })).get(0);
    // System.out.println("approxElem="+approxElement);
    IntArrayList approxRanks = binaryMultiSearch(exactFinder.buffer, approxElement);
    int from = approxRanks.get(0);
    int to = approxRanks.get(1);
    int distance;
    if (from <= exactRank && exactRank <= to)
        distance = 0;
    else {
        if (from > exactRank)
            distance = Math.abs(from - exactRank);
        else
            distance = Math.abs(exactRank - to);
    }
    double epsilon = (double) distance / (double) N;
    return epsilon;
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList) IntArrayList(cern.colt.list.IntArrayList)

Aggregations

IntArrayList (cern.colt.list.IntArrayList)26 DoubleArrayList (cern.colt.list.DoubleArrayList)6 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)2 ArrayList (java.util.ArrayList)1 ChiSquaredDistribution (org.apache.commons.math3.distribution.ChiSquaredDistribution)1 ChiSquareTest (org.apache.commons.math3.stat.inference.ChiSquareTest)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)1