@Test
public void testAdd() {

    int n = 1048575;
    int range = 12345;
    
    AMSSketch sketch = new AMSSketch(5, 512);
    StreamGenerator gen = new StreamGenerator(0.8, n, range);
    gen.generate();
    gen.exact();
    
    long[] stream = gen.stream;
    long sumsq = gen.sumsq;
    
    for (int i=1; i<=range; i++) 
        sketch.add(stream[i], 1);  
    
    // actual frequency
    RealCounting<Long> actualFreq = new RealCounting<Long>();
    for (int i=1; i<=range; i++)
        actualFreq.add(stream[i], 1);      
    
    List<CountEntry<Long>> topk = actualFreq.peek(10);
    
    System.out.println("Frequency Table\n" + StringUtils.repeat("-", 80));
    System.out.println("Item\tactual\testimated");
    for (CountEntry<Long> item : topk) {
        System.out.println(item.getItem() + "\t" 
                + item.getFrequency() + "\t" 
                + sketch.estimateCount(item.getItem()));
    }
    
    System.out.println("Exact F2: " + sumsq);
    System.out.println("Estimated F2: " + sketch.estimateF2());
}