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;
}
Aggregations