<s>
In	O
statistics	O
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
(	O
KDE	O
)	O
is	O
the	O
application	O
of	O
kernel	B-General_Concept
smoothing	I-General_Concept
for	O
probability	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
,	O
i.e.	O
,	O
a	O
non-parametric	B-General_Concept
method	I-General_Concept
to	O
estimate	O
the	O
probability	O
density	O
function	O
of	O
a	O
random	O
variable	O
based	O
on	O
kernels	O
as	O
weights	B-Algorithm
.	O
</s>
<s>
KDE	O
answers	O
a	O
fundamental	O
data	B-Application
smoothing	I-Application
problem	O
where	O
inferences	O
about	O
the	O
population	O
are	O
made	O
,	O
based	O
on	O
a	O
finite	O
data	O
sample	O
.	O
</s>
<s>
One	O
of	O
the	O
famous	O
applications	O
of	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
in	O
estimating	O
the	O
class-conditional	O
marginal	O
densities	O
of	O
data	O
when	O
using	O
a	O
naive	B-General_Concept
Bayes	I-General_Concept
classifier	I-General_Concept
,	O
which	O
can	O
improve	O
its	O
prediction	O
accuracy	O
.	O
</s>
<s>
Let	O
(	O
x1	O
,	O
x2	O
,	O
...	O
,	O
xn	O
)	O
be	O
independent	O
and	O
identically	O
distributed	O
samples	O
drawn	O
from	O
some	O
univariate	B-General_Concept
distribution	O
with	O
an	O
unknown	O
density	O
ƒ	O
at	O
any	O
given	O
point	O
x	O
.	O
</s>
<s>
where	O
K	O
is	O
the	O
kernel	O
—	O
a	O
non-negative	O
function	O
—	O
and	O
is	O
a	O
smoothing	B-Application
parameter	O
called	O
the	O
bandwidth	O
.	O
</s>
<s>
The	O
construction	O
of	O
a	O
kernel	B-General_Concept
density	I-General_Concept
estimate	I-General_Concept
finds	O
interpretations	O
in	O
fields	O
outside	O
of	O
density	B-General_Concept
estimation	I-General_Concept
.	O
</s>
<s>
Similar	O
methods	O
are	O
used	O
to	O
construct	O
discrete	B-Algorithm
Laplace	I-Algorithm
operators	I-Algorithm
on	O
point	O
clouds	O
for	O
manifold	O
learning	O
(	O
e.g.	O
</s>
<s>
diffusion	B-Algorithm
map	I-Algorithm
)	O
.	O
</s>
<s>
Kernel	B-General_Concept
density	I-General_Concept
estimates	I-General_Concept
are	O
closely	O
related	O
to	O
histograms	B-Algorithm
,	O
but	O
can	O
be	O
endowed	O
with	O
properties	O
such	O
as	O
smoothness	O
or	O
continuity	O
by	O
using	O
a	O
suitable	O
kernel	O
.	O
</s>
<s>
For	O
the	O
histogram	B-Algorithm
,	O
first	O
,	O
the	O
horizontal	O
axis	O
is	O
divided	O
into	O
sub-intervals	O
or	O
bins	O
which	O
cover	O
the	O
range	O
of	O
the	O
data	O
:	O
In	O
this	O
case	O
,	O
six	O
bins	O
each	O
of	O
width	O
2	O
.	O
</s>
<s>
For	O
the	O
kernel	B-General_Concept
density	I-General_Concept
estimate	I-General_Concept
,	O
normal	O
kernels	O
with	O
variance	O
2.25	O
(	O
indicated	O
by	O
the	O
red	O
dashed	O
lines	O
)	O
are	O
placed	O
on	O
each	O
of	O
the	O
data	O
points	O
xi	O
.	O
</s>
<s>
The	O
kernels	O
are	O
summed	O
to	O
make	O
the	O
kernel	B-General_Concept
density	I-General_Concept
estimate	I-General_Concept
(	O
solid	O
blue	O
curve	O
)	O
.	O
</s>
<s>
The	O
smoothness	O
of	O
the	O
kernel	B-General_Concept
density	I-General_Concept
estimate	I-General_Concept
(	O
compared	O
to	O
the	O
discreteness	O
of	O
the	O
histogram	B-Algorithm
)	O
illustrates	O
how	O
kernel	B-General_Concept
density	I-General_Concept
estimates	I-General_Concept
converge	O
faster	O
to	O
the	O
true	O
underlying	O
density	O
for	O
continuous	O
random	O
variables	O
.	O
</s>
<s>
To	O
illustrate	O
its	O
effect	O
,	O
we	O
take	O
a	O
simulated	O
random	O
sample	O
from	O
the	O
standard	O
normal	O
distribution	O
(	O
plotted	O
at	O
the	O
blue	O
spikes	O
in	O
the	O
rug	B-Application
plot	I-Application
on	O
the	O
horizontal	O
axis	O
)	O
.	O
</s>
<s>
The	O
black	O
curve	O
with	O
a	O
bandwidth	O
of	O
h	O
=	O
0.337	O
is	O
considered	O
to	O
be	O
optimally	O
smoothed	B-Application
since	O
its	O
density	O
estimate	O
is	O
close	O
to	O
the	O
true	O
density	O
.	O
</s>
<s>
An	O
extreme	O
situation	O
is	O
encountered	O
in	O
the	O
limit	O
(	O
no	O
smoothing	B-Application
)	O
,	O
where	O
the	O
estimate	O
is	O
a	O
sum	O
of	O
n	O
delta	O
functions	O
centered	O
at	O
the	O
coordinates	O
of	O
analyzed	O
samples	O
.	O
</s>
<s>
The	O
most	O
common	O
optimality	O
criterion	O
used	O
to	O
select	O
this	O
parameter	O
is	O
the	O
expected	O
L2	O
risk	O
function	O
,	O
also	O
termed	O
the	O
mean	B-General_Concept
integrated	I-General_Concept
squared	I-General_Concept
error	I-General_Concept
:	O
</s>
<s>
The	O
AMISE	O
is	O
the	O
asymptotic	O
MISE	B-General_Concept
,	O
i.e.	O
</s>
<s>
Several	O
review	O
studies	O
have	O
been	O
undertaken	O
to	O
compare	O
their	O
efficacies	O
,	O
with	O
the	O
general	O
consensus	O
that	O
the	O
plug-in	O
selectors	O
and	O
cross	B-Application
validation	I-Application
selectors	O
are	O
the	O
most	O
useful	O
over	O
a	O
wide	O
range	O
of	O
data	O
sets	O
.	O
</s>
<s>
It	O
can	O
be	O
shown	O
that	O
,	O
under	O
weak	O
assumptions	O
,	O
there	O
cannot	O
exist	O
a	O
non-parametric	B-General_Concept
estimator	O
that	O
converges	O
at	O
a	O
faster	O
rate	O
than	O
the	O
kernel	O
estimator	O
.	O
</s>
<s>
If	O
the	O
bandwidth	O
is	O
not	O
held	O
fixed	O
,	O
but	O
is	O
varied	O
depending	O
upon	O
the	O
location	O
of	O
either	O
the	O
estimate	O
(	O
balloon	O
estimator	O
)	O
or	O
the	O
samples	O
(	O
pointwise	O
estimator	O
)	O
,	O
this	O
produces	O
a	O
particularly	O
powerful	O
method	O
termed	O
adaptive	B-General_Concept
or	I-General_Concept
variable	I-General_Concept
bandwidth	I-General_Concept
kernel	I-General_Concept
density	I-General_Concept
estimation	I-General_Concept
.	O
</s>
<s>
Bandwidth	O
selection	O
for	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
of	O
heavy-tailed	O
distributions	O
is	O
relatively	O
difficult	O
.	O
</s>
<s>
If	O
Gaussian	O
basis	O
functions	O
are	O
used	O
to	O
approximate	O
univariate	B-General_Concept
data	O
,	O
and	O
the	O
underlying	O
density	O
being	O
estimated	O
is	O
Gaussian	O
,	O
the	O
optimal	O
choice	O
for	O
h	O
(	O
that	O
is	O
,	O
the	O
bandwidth	O
that	O
minimises	O
the	O
mean	B-General_Concept
integrated	I-General_Concept
squared	I-General_Concept
error	I-General_Concept
)	O
is	O
:	O
</s>
<s>
This	O
is	O
often	O
done	O
empirically	O
by	O
replacing	O
the	O
standard	B-General_Concept
deviation	I-General_Concept
by	O
the	O
parameter	O
below	O
:	O
</s>
<s>
where	O
IQR	B-General_Concept
is	O
the	O
interquartile	B-General_Concept
range	I-General_Concept
.	O
</s>
<s>
from	O
a	O
sample	O
of	O
200	O
points	O
,	O
the	O
figure	O
on	O
the	O
right	O
shows	O
the	O
true	O
density	O
and	O
two	O
kernel	B-General_Concept
density	I-General_Concept
estimates	I-General_Concept
—	O
one	O
using	O
the	O
rule-of-thumb	O
bandwidth	O
,	O
and	O
the	O
other	O
using	O
a	O
solve-the-equation	O
bandwidth	O
.	O
</s>
<s>
Knowing	O
the	O
characteristic	O
function	O
,	O
it	O
is	O
possible	O
to	O
find	O
the	O
corresponding	O
probability	O
density	O
function	O
through	O
the	O
Fourier	B-Algorithm
transform	I-Algorithm
formula	O
.	O
</s>
<s>
To	O
circumvent	O
this	O
problem	O
,	O
the	O
estimator	O
is	O
multiplied	O
by	O
a	O
damping	O
function	O
,	O
which	O
is	O
equal	O
to	O
1	O
at	O
the	O
origin	B-Application
and	O
then	O
falls	O
to	O
0	O
at	O
infinity	O
.	O
</s>
<s>
where	O
K	O
is	O
the	O
Fourier	B-Algorithm
transform	I-Algorithm
of	O
the	O
damping	O
function	O
ψ	O
.	O
</s>
<s>
Thus	O
the	O
kernel	B-General_Concept
density	I-General_Concept
estimator	I-General_Concept
coincides	O
with	O
the	O
characteristic	O
function	O
density	O
estimator	O
.	O
</s>
<s>
Note	O
that	O
one	O
can	O
use	O
the	O
mean	B-Algorithm
shift	I-Algorithm
algorithm	O
to	O
compute	O
the	O
estimator	O
numerically	O
.	O
</s>
<s>
A	O
non-exhaustive	O
list	O
of	O
software	O
implementations	O
of	O
kernel	B-General_Concept
density	I-General_Concept
estimators	I-General_Concept
includes	O
:	O
</s>
<s>
In	O
Analytica	B-Language
release	O
4.4	O
,	O
the	O
Smoothing	B-Application
option	O
for	O
PDF	O
results	O
uses	O
KDE	O
,	O
and	O
from	O
expressions	O
it	O
is	O
available	O
via	O
the	O
built-in	O
Pdf	O
function	O
.	O
</s>
<s>
In	O
C/C	O
++	O
,	O
is	O
a	O
library	O
that	O
can	O
be	O
used	O
to	O
compute	O
kernel	B-General_Concept
density	I-General_Concept
estimates	I-General_Concept
using	O
normal	O
kernels	O
.	O
</s>
<s>
MATLAB	B-Language
interface	O
available	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
is	O
a	O
library	O
for	O
variable	B-General_Concept
kernel	I-General_Concept
density	I-General_Concept
estimation	I-General_Concept
.	O
</s>
<s>
In	O
C++	B-Language
,	O
mlpack	B-Language
is	O
a	O
library	O
that	O
can	O
compute	O
KDE	O
using	O
many	O
different	O
kernels	O
.	O
</s>
<s>
Python	B-Language
and	O
R	B-Language
interfaces	O
are	O
available	O
.	O
</s>
<s>
In	O
CrimeStat	O
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
using	O
five	O
different	O
kernel	O
functions	O
–	O
normal	O
,	O
uniform	O
,	O
quartic	O
,	O
negative	O
exponential	O
,	O
and	O
triangular	O
.	O
</s>
<s>
Kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
also	O
used	O
in	O
interpolating	O
a	O
Head	O
Bang	O
routine	O
,	O
in	O
estimating	O
a	O
two-dimensional	O
Journey-to-crime	O
density	O
function	O
,	O
and	O
in	O
estimating	O
a	O
three-dimensional	O
Bayesian	O
Journey-to-crime	O
estimate	O
.	O
</s>
<s>
In	O
ESRI	O
products	O
,	O
kernel	B-General_Concept
density	I-General_Concept
mapping	O
is	O
managed	O
out	O
of	O
the	O
Spatial	O
Analyst	O
toolbox	O
and	O
uses	O
the	O
Quartic(biweight )	O
kernel	O
.	O
</s>
<s>
In	O
Excel	B-Application
,	O
the	O
Royal	O
Society	O
of	O
Chemistry	O
has	O
created	O
an	O
add-in	O
to	O
run	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
based	O
on	O
their	O
.	O
</s>
<s>
In	O
gnuplot	B-Application
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
by	O
the	O
smooth	O
kdensity	O
option	O
,	O
the	O
datafile	O
can	O
contain	O
a	O
weight	O
and	O
bandwidth	O
for	O
each	O
point	O
,	O
or	O
the	O
bandwidth	O
can	O
be	O
set	O
automatically	O
according	O
to	O
"	O
Silverman	O
's	O
rule	O
of	O
thumb	O
"	O
(	O
see	O
above	O
)	O
.	O
</s>
<s>
In	O
Haskell	B-Language
,	O
kernel	B-General_Concept
density	I-General_Concept
is	O
implemented	O
in	O
the	O
package	O
.	O
</s>
<s>
In	O
IGOR	B-Application
Pro	I-Application
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
by	O
the	O
StatsKDE	O
operation	O
(	O
added	O
in	O
Igor	B-Application
Pro	I-Application
7.00	O
)	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
the	O
Weka	B-Language
(	O
machine	O
learning	O
)	O
package	O
provides	O
,	O
among	O
others	O
.	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
the	O
visualization	O
package	O
D3.js	B-Language
offers	O
a	O
KDE	O
package	O
in	O
its	O
science.stats	O
package	O
.	O
</s>
<s>
In	O
JMP	B-Language
,	O
the	O
Graph	O
Builder	O
platform	O
utilizes	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
to	O
provide	O
contour	O
plots	O
and	O
high	O
density	O
regions	O
(	O
HDRs	O
)	O
for	O
bivariate	O
densities	O
,	O
and	O
violin	O
plots	O
and	O
HDRs	O
for	O
univariate	B-General_Concept
densities	O
.	O
</s>
<s>
Bivariate	O
and	O
univariate	B-General_Concept
kernel	B-General_Concept
density	I-General_Concept
estimates	I-General_Concept
are	O
also	O
provided	O
by	O
the	O
Fit	O
Y	O
by	O
X	O
and	O
Distribution	O
platforms	O
,	O
respectively	O
.	O
</s>
<s>
In	O
Julia	B-Application
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
in	O
the	O
package	O
.	O
</s>
<s>
In	O
MATLAB	B-Language
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
through	O
the	O
ksdensity	O
function	O
(	O
Statistics	O
Toolbox	O
)	O
.	O
</s>
<s>
As	O
of	O
the	O
2018a	O
release	O
of	O
MATLAB	B-Language
,	O
both	O
the	O
bandwidth	O
and	O
kernel	B-General_Concept
smoother	I-General_Concept
can	O
be	O
specified	O
,	O
including	O
other	O
options	O
such	O
as	O
specifying	O
the	O
range	O
of	O
the	O
kernel	B-General_Concept
density	I-General_Concept
.	O
</s>
<s>
A	O
free	O
MATLAB	B-Language
toolbox	O
with	O
implementation	O
of	O
kernel	B-Language
regression	I-Language
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
,	O
kernel	O
estimation	O
of	O
hazard	O
function	O
and	O
many	O
others	O
is	O
available	O
on	O
(	O
this	O
toolbox	O
is	O
a	O
part	O
of	O
the	O
book	O
)	O
.	O
</s>
<s>
In	O
Mathematica	B-Language
,	O
numeric	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
by	O
the	O
function	O
SmoothKernelDistribution	O
and	O
symbolic	O
estimation	O
is	O
implemented	O
using	O
the	O
function	O
KernelMixtureDistribution	O
both	O
of	O
which	O
provide	O
data-driven	O
bandwidths	O
.	O
</s>
<s>
In	O
Minitab	B-Application
,	O
the	O
Royal	O
Society	O
of	O
Chemistry	O
has	O
created	O
a	O
macro	O
to	O
run	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
based	O
on	O
their	O
Analytical	O
Methods	O
Committee	O
Technical	O
Brief	O
4	O
.	O
</s>
<s>
In	O
the	O
NAG	O
Library	O
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
via	O
the	O
g10ba	O
routine	O
(	O
available	O
in	O
both	O
the	O
Fortran	O
and	O
the	O
C	B-Language
versions	O
of	O
the	O
Library	O
)	O
.	O
</s>
<s>
In	O
,	O
C++	B-Language
kernel	B-General_Concept
density	I-General_Concept
methods	O
focus	O
on	O
data	O
from	O
the	O
Special	O
Euclidean	O
group	O
.	O
</s>
<s>
In	O
Octave	B-Language
,	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
implemented	O
by	O
the	O
kernel_density	O
option	O
(	O
econometrics	O
package	O
)	O
.	O
</s>
<s>
In	O
Origin	B-Application
,	O
2D	O
kernel	B-General_Concept
density	I-General_Concept
plot	O
can	O
be	O
made	O
from	O
its	O
user	O
interface	O
,	O
and	O
two	O
functions	O
,	O
Ksdensity	O
for	O
1D	O
and	O
Ks2density	O
for	O
2D	O
can	O
be	O
used	O
from	O
its	O
,	O
Python	B-Language
,	O
or	O
C	B-Language
code	O
.	O
</s>
<s>
In	O
Python	B-Language
,	O
many	O
implementations	O
exist	O
:	O
in	O
the	O
,	O
SciPy	O
(	O
scipy.stats.gaussian_kde	O
)	O
,	O
Statsmodels	O
(	O
KDEUnivariate	O
and	O
KDEMultivariate	O
)	O
,	O
and	O
scikit-learn	B-Application
(	O
KernelDensity	O
)	O
(	O
see	O
comparison	O
)	O
.	O
</s>
<s>
supports	O
weighted	B-Algorithm
data	O
and	O
its	O
FFT	O
implementation	O
is	O
orders	O
of	O
magnitude	O
faster	O
than	O
the	O
other	O
implementations	O
.	O
</s>
<s>
The	O
package	O
for	O
weighted	B-Algorithm
and	O
correlated	O
MCMC	O
samples	O
supports	O
optimized	O
bandwidth	O
,	O
boundary	O
correction	O
and	O
higher-order	O
methods	O
for	O
1D	O
and	O
2D	O
distributions	O
.	O
</s>
<s>
One	O
newly	O
used	O
package	O
for	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
is	O
seaborn	O
(	O
import	O
seaborn	O
as	O
sns	O
,	O
sns.kdeplot( )	O
)	O
.	O
</s>
<s>
In	O
R	B-Language
,	O
it	O
is	O
implemented	O
through	O
density	O
in	O
the	O
base	O
distribution	O
,	O
and	O
bw.nrd0	O
function	O
is	O
used	O
in	O
stats	O
package	O
,	O
this	O
function	O
uses	O
the	O
optimized	O
formula	O
in	O
Silverman	O
's	O
book	O
.	O
</s>
<s>
bkde	O
in	O
the	O
,	O
ParetoDensityEstimation	O
in	O
the	O
(	O
for	O
pareto	O
distribution	O
density	B-General_Concept
estimation	I-General_Concept
)	O
,	O
kde	O
in	O
the	O
,	O
dkden	O
and	O
dbckden	O
in	O
the	O
(	O
latter	O
for	O
boundary	O
corrected	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
for	O
bounded	O
support	O
)	O
,	O
npudens	O
in	O
the	O
(	O
numeric	O
and	O
categorical	O
data	O
)	O
,	O
sm.density	O
in	O
the	O
.	O
</s>
<s>
For	O
an	O
implementation	O
of	O
the	O
kde.R	O
function	O
,	O
which	O
does	O
not	O
require	O
installing	O
any	O
packages	O
or	O
libraries	O
,	O
see	O
.	O
</s>
<s>
The	O
,	O
dedicated	O
to	O
urban	O
analysis	O
,	O
implements	O
kernel	B-General_Concept
density	I-General_Concept
estimation	I-General_Concept
through	O
kernel_smoothing	O
.	O
</s>
<s>
In	O
SAS	B-Language
,	O
proc	O
kde	O
can	O
be	O
used	O
to	O
estimate	O
univariate	B-General_Concept
and	O
bivariate	O
kernel	B-General_Concept
densities	I-General_Concept
.	O
</s>
<s>
In	O
Stata	B-Algorithm
,	O
it	O
is	O
implemented	O
through	O
kdensity	O
;	O
for	O
example	O
histogram	B-Algorithm
x	O
,	O
kdensity	O
.	O
</s>
<s>
Alternatively	O
a	O
free	O
Stata	B-Algorithm
module	O
KDENS	O
is	O
available	O
allowing	O
a	O
user	O
to	O
estimate	O
1D	O
or	O
2D	O
density	O
functions	O
.	O
</s>
<s>
In	O
Swift	B-Application
,	O
it	O
is	O
implemented	O
through	O
SwiftStats.KernelDensityEstimation	O
in	O
the	O
open-source	O
statistics	O
library	O
.	O
</s>
