Search in sources :

Example 1 with UpdateSketch

use of com.yahoo.sketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class BoundsOnRatiosInThetaSketchedSetsTest method checkAbnormalReturns.

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkAbnormalReturns() {
    //4K
    UpdateSketch skA = Sketches.updateSketchBuilder().build();
    UpdateSketch skC = Sketches.updateSketchBuilder().build();
    int uA = 100000;
    int uC = 10000;
    for (int i = 0; i < uA; i++) {
        skA.update(i);
    }
    for (int i = 0; i < uC; i++) {
        skC.update(i + uA / 2);
    }
    BoundsOnRatiosInThetaSketchedSets.getEstimateOfBoverA(skA, skC);
}
Also used : UpdateSketch(com.yahoo.sketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 2 with UpdateSketch

use of com.yahoo.sketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class BoundsOnRatiosInThetaSketchedSetsTest method checkNormalReturns.

@Test
public void checkNormalReturns() {
    //4K
    UpdateSketch skA = Sketches.updateSketchBuilder().build();
    UpdateSketch skC = Sketches.updateSketchBuilder().build();
    int uA = 10000;
    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);
    }
    Intersection inter = Sketches.setOperationBuilder().buildIntersection();
    inter.update(skA);
    inter.update(skC);
    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);
}
Also used : Intersection(com.yahoo.sketches.theta.Intersection) CompactSketch(com.yahoo.sketches.theta.CompactSketch) UpdateSketch(com.yahoo.sketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 3 with UpdateSketch

use of com.yahoo.sketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class FamilyTest method checkFamily.

@Test
public void checkFamily() {
    UpdateSketch sk = UpdateSketch.builder().build();
    String sname = sk.getClass().getSimpleName();
    String fname = Family.objectToFamily(sk).toString();
    assertTrue(sname.toUpperCase().contains(fname));
//    for (Family f : Family.values()) {
//      String fstr = f.toString();
//      println("Name: "+fstr + ": ID: "+f.getID());
//    }
}
Also used : UpdateSketch(com.yahoo.sketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Aggregations

UpdateSketch (com.yahoo.sketches.theta.UpdateSketch)3 Test (org.testng.annotations.Test)3 CompactSketch (com.yahoo.sketches.theta.CompactSketch)1 Intersection (com.yahoo.sketches.theta.Intersection)1