in commons-statistics-inference/src/main/java/org/apache/commons/statistics/inference/UnconditionedExactTest.java [416:448]
void add(double k, double v) {
// Store only a single NaN
if (Double.isNaN(v)) {
if (size == 0) {
// No requirement to check capacity
data[size++] = new double[] {k, v};
}
return;
}
// Here values are non-NaN.
// If higher then do not store.
if (v > threshold) {
return;
}
// Check if lower than the current minima.
if (v < min) {
min = v;
// Get new threshold
threshold = v + Math.abs(v) * eps;
// Remove existing entries above the threshold
int s = 0;
for (int i = 0; i < size; i++) {
// This will filter NaN values
if (data[i][1] <= threshold) {
data[s++] = data[i];
}
}
size = s;
// Caution: This does not clear stale data
// by setting all values in [newSize, oldSize) = null
}
addPair(k, v);
}