Skip to contents

A nonparametric density estimate built from a sample by summing a kernel centered at each observation. Mirrors the C# KernelDensity composite.

Usage

dist_kde(data, kernel = "Gaussian", bandwidth = NULL, bounded_by_data = TRUE)

Arguments

data

numeric vector of observations the density is built from.

kernel

the kernel shape: "Gaussian" (the default), "Epanechnikov", "Triangular", or "Uniform".

bandwidth

the kernel bandwidth; NULL (the default) uses Silverman's rule of thumb.

bounded_by_data

whether the reported minimum and maximum are the smallest and largest observation (TRUE, the default) or extend three bandwidths past each. Those bounds gate dist_cdf() and dist_quantile(). The density is summed wherever you ask it, either way.

Value

a corehydro_dist of family "KernelDensity", accepted by every dist_*() verb.

Examples

d <- dist_kde(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
dist_cdf(d, 5.5)
#> [1] 0.5005659