Skip to main content

kde_curve

Function kde_curve 

Source
pub fn kde_curve(
    data: &[f64],
    bandwidth: Option<f64>,
    n_points: usize,
    cut: f64,
) -> Result<KdeCurve, StatsError>
Expand description

Evaluate a Gaussian KDE of data on a uniform grid.

  • bandwidthSome(h) to force a bandwidth, or None to derive one via silverman_bandwidth.
  • n_points — number of grid points; higher gives a smoother violin outline (values around 200 render cleanly). Clamped to at least 2.
  • cut — how far past the data range to extend, in bandwidths (a value of 3.0 captures the Gaussian tails without a visible cutoff).

Returns StatsError::EmptyInput for no finite data, or StatsError::InvalidBandwidth for a non-positive bandwidth (explicit or derived).