Content deleted Content added
→top: Typo fixing, fixed "Mahematical" by choosing a different "short description" |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 52:
for a practical overview with comparative simulation results.
=== Python
<syntaxhighlight lang="python3" line="1">
def algorithm_d(stream, s: int):
m = len(stream) # We assume that this is given to us in advance.
t = -1 # Note that Knuth indexes the stream from 1.
p = 1
a = 0
Line 63:
t += 1
a = stream[t]
u = uniform(0, 1)
buffer = list(filter(lambda x
if u < p:
if
buffer.append([u, a])
else:
buffer = sorted(buffer)
p = max(buffer[-1][0], u)
buffer.pop()
buffer.append([u, a])
return len(buffer) / p
</syntaxhighlight>
=== CVM
Compared to other approximation algorithms for the count-distinct problem the CVM Algorithm<ref>{{Cite
{{nowrap|Initialize <math> p \leftarrow 1 </math>}}
Line 148:
[[Category:Statistical algorithms]]
[[Category:Articles with example Python (programming language) code]]
|