We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d066bee commit a30b9d7Copy full SHA for a30b9d7
src/signal_analysis/yin.rs
@@ -94,13 +94,14 @@ fn difference_function(f: &[f64], lag: usize) -> f64 {
94
sum
95
}
96
97
+const EPSILON: f64 = 1e-10;
98
fn cumulative_mean_normalized_difference_function(df: &[f64], max_lag: usize) -> Vec<f64> {
99
let mut cmndf = vec![0.0; max_lag + 1];
100
cmndf[0] = 1.0;
101
let mut sum = 0.0;
102
for lag in 1..=max_lag {
103
sum += df[lag];
- cmndf[lag] = lag as f64 * df[lag] / if sum == 0.0 { 1e-10 } else { sum };
104
+ cmndf[lag] = lag as f64 * df[lag] / if sum == 0.0 { EPSILON } else { sum };
105
106
cmndf
107
0 commit comments