use of org.apache.datasketches.theta.CompactSketch in project sketches-core by DataSketches.
the class BoundsOnRatiosInThetaSketchedSetsTest method checkNormalReturns.
@Test
public void checkNormalReturns() {
// 4K
final UpdateSketch skA = Sketches.updateSketchBuilder().build();
final UpdateSketch skC = Sketches.updateSketchBuilder().build();
final int uA = 10000;
final int uC = 100000;
for (int i = 0; i < uA; i++) {
skA.update(i);
}
for (int i = 0; i < uC; i++) {
skC.update(i + (uA / 2));
}
final Intersection inter = Sketches.setOperationBuilder().buildIntersection();
inter.intersect(skA);
inter.intersect(skC);
final CompactSketch skB = inter.getResult();
double est = BoundsOnRatiosInThetaSketchedSets.getEstimateOfBoverA(skA, skB);
double lb = BoundsOnRatiosInThetaSketchedSets.getLowerBoundForBoverA(skA, skB);
double ub = BoundsOnRatiosInThetaSketchedSets.getUpperBoundForBoverA(skA, skB);
assertTrue(ub > est);
assertTrue(est > lb);
assertEquals(est, 0.5, .03);
println("ub : " + ub);
println("est: " + est);
println("lb : " + lb);
// skA is now empty
skA.reset();
est = BoundsOnRatiosInThetaSketchedSets.getEstimateOfBoverA(skA, skB);
lb = BoundsOnRatiosInThetaSketchedSets.getLowerBoundForBoverA(skA, skB);
ub = BoundsOnRatiosInThetaSketchedSets.getUpperBoundForBoverA(skA, skB);
println("ub : " + ub);
println("est: " + est);
println("lb : " + lb);
// Now both are empty
skC.reset();
est = BoundsOnRatiosInThetaSketchedSets.getEstimateOfBoverA(skA, skC);
lb = BoundsOnRatiosInThetaSketchedSets.getLowerBoundForBoverA(skA, skC);
ub = BoundsOnRatiosInThetaSketchedSets.getUpperBoundForBoverA(skA, skC);
println("ub : " + ub);
println("est: " + est);
println("lb : " + lb);
}
Aggregations