code: public int estimateCardinality() {
      double t = bits.bitCount();
      double m = bits.bitSize();
      double k = numHashFunctions;
  
      double x = Math.log(1 - (t / m));
      double y = k * Math.log(1 - (1 / m));
  
      return (int) Math.ceil(x / y);
    }
docs: Estimates the cardinality of the bloom filter based on the bloom filter length (m), number of bits set to true (t)
  and number of hash functions (k). The estimation is derived from the maximum likelihood value for the number of
  hashed elements as defined in "Cardinality estimation and dynamic length adaptation for Bloom filters" from
  O. Papapetrou, W. Silberski, W. Nedjl.