use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testNormalDistributionHighVarianceValuesArray.
@Test
public void testNormalDistributionHighVarianceValuesArray() {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
NormalDistribution normal = new NormalDistribution(0, 1);
List<Double> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES; i++) {
double value = normal.sample();
tDigest.add(value);
list.add(value);
}
sort(list);
double[] values = new double[quantiles.length];
for (int i = 0; i < quantiles.length; i++) {
values[i] = list.get((int) (quantiles[i] * NUMBER_OF_ENTRIES));
}
assertBlockValues(values, STANDARD_ERROR, tDigest);
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testAddElementsInOrderQuantileArray.
@Test
public void testAddElementsInOrderQuantileArray() {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Double> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES; i++) {
tDigest.add(i);
list.add((double) i);
}
sort(list);
assertBlockQuantiles(quantiles, STANDARD_ERROR, list, tDigest);
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testMergeTwoNormalDistributions.
@Test
public void testMergeTwoNormalDistributions() {
TDigest tDigest1 = createTDigest(STANDARD_COMPRESSION_FACTOR);
TDigest tDigest2 = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Double> list = new ArrayList<>();
NormalDistribution normal = new NormalDistribution(0, 50);
for (int i = 0; i < NUMBER_OF_ENTRIES / 2; i++) {
double value1 = normal.sample();
double value2 = normal.sample();
tDigest1.add(value1);
tDigest2.add(value2);
list.add(value1);
list.add(value2);
}
tDigest1.merge(tDigest2);
sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertContinuousQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest1);
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testMergeTwoDistributionsWithoutOverlap.
@Test
public void testMergeTwoDistributionsWithoutOverlap() {
TDigest tDigest1 = createTDigest(STANDARD_COMPRESSION_FACTOR);
TDigest tDigest2 = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES / 2; i++) {
tDigest1.add(i);
tDigest2.add(i + NUMBER_OF_ENTRIES / 2);
list.add(i);
list.add(i + NUMBER_OF_ENTRIES / 2);
}
tDigest1.merge(tDigest2);
sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertDiscreteQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest1);
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testMergeTwoDistributionsWithOverlap.
@Test
public void testMergeTwoDistributionsWithOverlap() {
TDigest tDigest1 = createTDigest(STANDARD_COMPRESSION_FACTOR);
TDigest tDigest2 = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES / 2; i++) {
tDigest1.add(i);
tDigest2.add(i);
list.add(i);
list.add(i);
}
tDigest2.merge(tDigest1);
sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertDiscreteQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest2);
}
}
Aggregations