TEWMA { public double add(Object item, double quantity, long timestamp) { int[] idx = indexes(item); double minCounter = getMinCounter(idx, timestamp); double newCounter = minCounter + quantity * logBeta; if (newCounter > 1.0e99) throw new AssertionError("newCounter shouldn't be greater than 1.0e99."); for (int i=0; i<nhash; i++) if (counters[idx[i]] < newCounter) counters[idx[i]] = newCounter; return newCounter; } TEWMA(int nhash, int shash, double beta, double w); double add(Object item, double quantity, long timestamp); double check(Object item, long timestamp);  }
@Test public void testAdd() { System.out.println("testAdd"); TEWMA tewma = new TEWMA(16, 24, 0.3, 10); double value = tewma.add(272, 1, System.currentTimeMillis()/1000); System.out.println("Value: " + value); assertEquals(Math.ceil(1.203972), Math.ceil(value), 0); }