Add kernel weighting functions#108
Conversation
| tricube(u) | ||
| } | ||
| } | ||
| pub const TRICUBE: Tricube = Tricube; |
There was a problem hiding this comment.
Why are you creating a constant version of those functions? Why can't the user use Tricube instead of TRICUBE?
There was a problem hiding this comment.
Thanks for the feedback!
My goal with the constants was mainly to provide a small ergonomic convenience, letting users treat kernels as predeclared value singletons (e.g., smooth(TRICUBE, data)) instead of having to instantiate the unit structs directly. Although, I’m totally fine with removing them if the preference is to keep the API minimal and rely on the unit structs directly. I’ll update the PR accordingly if that’s the desired direction.
There was a problem hiding this comment.
I'm not a maintainer here, I was just curious. Don't change anything for me :)
Summary
This PR adds a new module
kernel_weightsproviding common statistical kernel functions used in local regression and kernel density estimation.Details
tricubeepanechnikovgaussiantriangularquartic(biweight)Tricube,Gaussian,Epanechnikov,Triangular,Quartic) implementing a newKernelFntrait.fn(f64) -> f64to be used directly asKernelFn.#[must_use]attributes.Motivation
Kernel weighting functions are widely used in nonparametric statistics (LOESS, KDE, SVMs).
Adding them directly to
ndarray-statsprovides a reusable foundation for local regression and density estimation tools without external dependencies.Checklist
cargo test --test kernel_weights)cargo fmtandcargo clippy --all-targets -- -D warningsclean