alpha
Login
or
Join now
urschrei.eurosky.social
/
cvmcount
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Rust implementation of the CVM algorithm for counting distinct elements in a stream
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Just return usize for the buffer size
author
Stephan Hügel
date
2 years ago
(May 23, 2024, 2:50 PM +0100)
commit
024ed37b
024ed37b92d66f59fa26ba1aaa3959303cfda00f
parent
881ce751
881ce7511fec7d05a0c4361d98b71f4b77b7b88a
+4
-4
1 changed file
Expand all
Collapse all
Unified
Split
src
lib.rs
+4
-4
src/lib.rs
Reviewed
···
30
30
pub fn new(epsilon: f64, delta: f64, stream_size: usize) -> Self {
31
31
let bufsize = buffer_size(epsilon, delta, stream_size);
32
32
Self {
33
33
-
buf_size: bufsize as usize,
34
34
-
buf: Vec::with_capacity(bufsize as usize),
33
33
+
buf_size: bufsize,
34
34
+
buf: Vec::with_capacity(bufsize),
35
35
probability: 1.0,
36
36
rng: rand::thread_rng(),
37
37
re: Regex::new(r"[^\w\s]").unwrap(),
···
71
71
}
72
72
73
73
// Calculate threshold (buf_size) value for the F0-Estimator algorithm
74
74
-
fn buffer_size(epsilon: f64, delta: f64, stream_size: usize) -> u32 {
75
75
-
((12.0 / epsilon.powf(2.0)) * ((8.0 * stream_size as f64) / delta).log2()).ceil() as u32
74
74
+
fn buffer_size(epsilon: f64, delta: f64, stream_size: usize) -> usize {
75
75
+
((12.0 / epsilon.powf(2.0)) * ((8.0 * stream_size as f64) / delta).log2()).ceil() as usize
76
76
}