File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ def __init__(self, size: int = 8) -> None:
14
14
self .bitstring = 0b0
15
15
self .size = size
16
16
17
- def add (self , value : str ):
17
+ def add (self , value : str ) -> None :
18
18
h = self .hash_ (value )
19
19
self .bitstring |= h
20
20
print (
@@ -70,18 +70,18 @@ def random_string(size: int) -> str:
70
70
return "" .join (choices (ascii_lowercase + " " , k = size ))
71
71
72
72
73
- def test_probability (m : int = 64 , n : int = 20 ) -> None :
74
- b = Bloom (size = m )
73
+ def test_probability (bits : int = 64 , n : int = 20 ) -> None :
74
+ b = Bloom (size = bits )
75
75
76
76
k = len (b .HASH_FUNCTIONS )
77
- estimated_error_rate_beforehand = (1 - (1 - 1 / m ) ** (k * n )) ** k
77
+ estimated_error_rate_beforehand = (1 - (1 - 1 / bits ) ** (k * n )) ** k
78
78
79
79
added = {random_string (10 ) for i in range (n )}
80
80
for a in added :
81
81
b .add (a )
82
82
83
83
n_ones = bin (b .bitstring ).count ("1" )
84
- estimated_error_rate = (n_ones / m ) ** k
84
+ estimated_error_rate = (n_ones / bits ) ** k
85
85
86
86
not_added = {random_string (10 ) for i in range (1000 )}
87
87
errors = 0
You can’t perform that action at this time.
0 commit comments