mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-07 10:00:55 +00:00
fix type
This commit is contained in:
parent
08bc970b7a
commit
044810991a
|
@ -45,7 +45,7 @@ class Bloom:
|
|||
|
||||
def hash(self, value):
|
||||
res = 0b0
|
||||
for func in HASH_FUNCTIONS:
|
||||
for func in self.HASH_FUNCTIONS:
|
||||
b = func(value.encode()).digest()
|
||||
position = int.from_bytes(b, "little") % self.size
|
||||
res |= 2**position
|
||||
|
@ -77,7 +77,7 @@ def test_probability(m=64, n=20):
|
|||
for a in added:
|
||||
b.add(a)
|
||||
|
||||
k = len(b.HASH_FUNCIONS)
|
||||
k = len(b.HASH_FUNCTIONS)
|
||||
|
||||
n_ones = bin(b.bitstring).count("1")
|
||||
expected_probability = (n_ones / m) ** k
|
||||
|
|
Loading…
Reference in New Issue
Block a user