Computing the approximate population of a bloom filter Given a bloom filter of size N-bits and K hash functions, of which M-bits (where M &lt;= N) of the filter are set.

Is it possible to approximate the number of elements inserted into the bloom filter?

Simple Example

I've been mulling over the following example, assuming a BF of 100-bits and 5 hash functions where 10-bits are set...

Best case scenario: Assuming the hash functions are really perfect and uniquely map a bit for some X number of values, then given 10-bits have been set we can say that there has only been 2 elements inserted into the BF

Worst case scenario: Assuming the hash functions are bad and consistently map to the same bit (yet unique amongst each other), then we can say 10 elements have been inserted into the BF

The range seems to be [2,10] where abouts in this range is probably determined by the false-positive probability of filter - I'm stuck at this point.
Yes.  From Wikipedia:

If you have inserted $i$ elements into a filter of size $n$ using $k$ hash functions, the probability that a certain bit is still 0 is 

$$
z = \left(1 - \frac{1}{n}\right)^{ki}
$$

You can measure this probability as the proportion of 0 bits in your filter.  Solving for $i$ gives

$$
i = \frac{\ln(z)}{k\ln\left(1 - \frac{1}{n}\right)}
$$

I have used this in practice, and as long as your filter does not exceed its capacity, the error is generally less than 0.1% for filters up to millions of bits.  As the filter exceeds its capacity, the error of course goes up.