kde: Kernel Density Estimation (KDE)

View source: R/RcppExports.R

Kernel Density EstimationR Documentation

Kernel Density Estimation (KDE)

Description

Kernel density estimation of a univariate sample using a Gaussian kernel.

Usage

kde(y, h, ncores = 1)

Arguments

y

A numeric vector containing the sample data.

h

A numeric value for boundwidth.

ncores

The number of cores to use. If greater than 1, parallel computing will take place. It is advisable to use it if you have many observations and or many variables, otherwise it will slow down the process. The default is 1, meaning that code is executed serially.

Details

The kernel density estimate (KDE) provides a smooth estimate of the probability density function of the sample data. In this implementation, the KDE is evaluated only at the observed sample points themselves.

Value

A numeric vector of density estimates corresponding to each observation in y.

Author(s)

Michail Tsagris and Christos Adam.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Christos Adam econp266@econ.soc.uoc.gr.

Examples

set.seed(123)
y <- rnorm(200)
dens <- kde(y, h = 1)

DER documentation built on Nov. 13, 2025, 1:07 a.m.