func NewFilter(N uint32, B uint32, maxFP float64) (*Filter, error) {
	if N == 0 {
		return nil, fmt.Errorf("number of insertions (N) must be > 0")
	}
	if B == 0 || B > 8 {
		return nil, fmt.Errorf("number of bits (%d) must be 0 < B <= 8", B)
	}
	if maxFP <= 0 || maxFP >= 1 {
		return nil, fmt.Errorf("max false positives must be 0 <= maxFP < 1: %f", maxFP)
	}
	M, K := computeOptimalValues(N, maxFP)
	maxCount := uint32((1 << B) - 1)
	numBytes := (M*B + 7) / 8
	bytes := make([]byte, numBytes, numBytes)
	return &Filter{
		K:        K,
		B:        B,
		M:        M,
		MaxCount: maxCount,
		Data:     bytes,
		hasher:   newHasher(),
	}, nil
}
NewFilter allocates and returns a new filter with expected number of
insertions N, Number of bits per slot B, and expected value of a false
positive < maxFP. Number of bits must be 0 < B <= 8.
package cbfilter
import (
	"fmt"
	"math"
)
type Filter struct {
	K        uint32   
	N        uint32   
	R        uint32   
	B        uint32   
	M        uint32   
	MaxCount uint32   
	Data     []byte   
	hasher   *hasher  
}
func probFalsePositive(N uint32, K uint32, M uint32) float64 {
	pSet := 1.0 - math.Pow(float64(M-1)/float64(M), float64(N*K))
	return math.Pow(pSet, float64(K))
}