70 likes | 79 Views
Probabilistic counting. A n-bit register can count up to 2 n events (0..2 n -1). init(c) ; reset tick(c) ; increment count(c) ; return count value. Skip some value to count farther. tick(c) flip a coin if head increment count(c) return value x 2
E N D
Probabilistic counting A n-bit register can count up to 2n events (0..2n-1) init(c) ; reset tick(c) ; increment count(c) ; return count value Skip some value to count farther Prabhas Chongstitvatana
tick(c) flip a coin if head increment count(c) return value x 2 Expected value after call count() t time is exactly t. Prabhas Chongstitvatana
tick(c) flip a coin if head increment count(c) return value x 2 Expected value after call count() t time is exactly t. Count exponentially farther (8-bit count more than 5 x 1076 events) count(c) return 2c – 1 Prabhas Chongstitvatana
Estimate number of tick 2c+1 – 1 with probability p 2c – 1 with prob. (1- p) Expected value (2c+1 – 1 ) p + (2c – 1 ) ( 1 – p ) = 2c + 2c p – 1 p = 2-c will get the correct expected value of count(c) Prabhas Chongstitvatana
init(c) c = 0 tick(c) For i = 1 to c do if coinflip = head then return c = c + 1 count(c) Return 2c – 1 Prabhas Chongstitvatana
Variance of count after m ticks is m(m-1)/2. The standard deviation is 70%. This means it cannot distinguish between one million and two million but it can distinguish between one million and 100 million. Prabhas Chongstitvatana
Count logarithmic farther count(c) = when e is small e = 1/30 count up to > 125000 events in 8-bit register with less than 24% relative error with confidence 95%. What is probability that tick(c) increment ? Prabhas Chongstitvatana