use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testAddElementsInOrder.
@Test
public void testAddElementsInOrder() {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES; i++) {
tDigest.add(i);
list.add(i);
}
for (int i = 0; i < quantiles.length; i++) {
assertDiscreteQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest);
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testPoissonDistribution.
@Test(enabled = false)
public void testPoissonDistribution() {
int trials = 10;
for (int k = 1; k < trials; k++) {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
PoissonDistribution poisson = new PoissonDistribution(k * 0.1);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES; i++) {
int sample = poisson.sample();
tDigest.add(sample);
list.add(sample);
}
Collections.sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertDiscreteQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest);
}
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testGeometricDistribution.
@Test(enabled = false)
public void testGeometricDistribution() {
int trials = 10;
for (int k = 1; k < trials; k++) {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
GeometricDistribution geometric = new GeometricDistribution(k * 0.1);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_ENTRIES; i++) {
int sample = geometric.sample();
tDigest.add(sample);
list.add(sample);
}
Collections.sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertDiscreteQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest);
}
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testMergeTwoNormalDistributionsGetQuantile.
@Test
public void testMergeTwoNormalDistributionsGetQuantile() {
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++) {
assertValueWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest1);
}
}
use of com.facebook.presto.tdigest.TDigest in project presto by prestodb.
the class TestTDigestFunctions method testMergeManyLargeNormalDistributions.
@Test
public void testMergeManyLargeNormalDistributions() {
TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR);
List<Double> list = new ArrayList<>();
NormalDistribution normal = new NormalDistribution(500, 20);
int digests = 1000;
for (int k = 0; k < digests; k++) {
TDigest current = createTDigest(STANDARD_COMPRESSION_FACTOR);
for (int i = 0; i < NUMBER_OF_ENTRIES / digests; i++) {
double value = normal.sample();
current.add(value);
list.add(value);
}
tDigest.merge(current);
}
sort(list);
for (int i = 0; i < quantiles.length; i++) {
assertContinuousQuantileWithinBound(quantiles[i], STANDARD_ERROR, list, tDigest);
}
}
Aggregations