We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 26cfa70 commit 5f145beCopy full SHA for 5f145be
1 file changed
crates/criterion_compat/criterion_fork/src/stats/univariate/kde/mod.rs
@@ -84,7 +84,15 @@ impl Bandwidth {
84
let n = A::cast(sample.len());
85
let sigma = sample.std_dev(None);
86
87
- sigma * (factor / n).powf(exponent)
+ let h = sigma * (factor / n).powf(exponent);
88
+ // CodSpeed addition:
89
+ // Silverman's rule of thumb can return zero if all samples have the same value,
90
+ // so we return epsilon in that case to avoid division by zero in the KDE
91
+ if h > A::cast(0) {
92
+ h
93
+ } else {
94
+ A::epsilon()
95
+ }
96
}
97
98
0 commit comments