I find this interesting, but somewhat sloppy writing. Examples:<p><i>&quot;Problem: Estimate the number of distinct items in a data stream that is too large to fit in memory&quot;</i><p>That is <i>not</i> what the title promises: the size of the stream.<p><i>&quot;assume the data in the stream consists of uniformly random integers between zero and N&quot;</i><p>I guess the lower bound is inclusive and the upper bound exclusive (that probably doesn&#x27;t matter in practice. It would matter if you want to estimate the number of different byte values in a data stream on a truly tiny device, but I would guess that anything that can do that division to get the estimate would have the 32 bytes to store a bitmask with 256 values)<p><i>&quot;Maintain a single integer xMin
[...]
expected value would be 1&#x2F;(xMin+1)&quot;</i><p>With xMin a nonnegative integer, that estimate (of the number of different values in the stream) would never get larger than 1. The code is correct; it multiplies by N to get a number between 1 and N (inclusive).