Skip to content

parham1998/Kernel-Density-Estimation

Repository files navigation

Kernel-Density-Estimation (warm-up project!)

Implementation of Kernel-Density-Estimation (KDE) with Matlab

smooth kernel function (Gaussian kernel)

1

example1

pdf

2

figure1 (N = 1000, h = 0.1)

first_exp(1)

figure2 (N = 1000, h = 0.01)

first_exp(2)

figure3 (N = 10000, h = 0.1)

first_exp(3)

example2

pdf

3

figure0 (real distribution)

second_exp_real_distribution

figure1 (N = 1000, h = 0.1)

second_exp(1)

figure2 (N = 1000, h = 0.01)

second_exp(2)

figure3 (N = 10000, h = 0.1)

second_exp(3)

results

As expected, the estimated density will be more accurate with more data points (see figure3 in example1 and example2). furthermore, a large ℎ will over-smooth the density estimation and mask the structure of the data, and a small ℎ will yield a density estimation that is spiky and very hard to interpret. (see image below)

4

I prefer using the smooth kernel function instead of the parzen window because parzen window yields density estimates that have discontinuities, and weights equally all points, regardless of their distance to the estimation point.

If we had unlimited data points, the best result would be obtained by bringing h near zero.