SSJ
3.3.1
Stochastic Simulation in Java
|
This static class provides methods to compute a kernel density estimator from a set of \(n\) individual observations \(x_0, …, x_{n-1}\), which define an empirical distribution. More...
Public Member Functions | |
void | evalDensity (double data[], ContinuousDistribution kern, double h, double[] evalPoints, double[] density, double epsilon0) |
Similar to \(computeDensity (dist, kern, h, evalPoints)\), but much more efficient for very large n. More... | |
Static Public Member Functions | |
static double [] | computeDensity (EmpiricalDist dist, ContinuousDistribution kern, double h, double[] Y) |
Given the empirical distribution dist , this method computes the kernel density estimate at each of the \(m\) evaluation points evalPoints[ \(j\)] , \(j= 0, 1, …, (m-1)\), where \(m\) is the length of EvalPoints , the kernel is kern.density(x) , and the bandwidth is \(h\). More... | |
This static class provides methods to compute a kernel density estimator from a set of \(n\) individual observations \(x_0, …, x_{n-1}\), which define an empirical distribution.
The methods return the estimated density either at a given point or on a grid or set of \(m\) predefined points. Some details on how a kernel density estimator is defined and how to select the kernel and the bandwidth \(h\) are given in the documentation of class
umontreal.ssj.randvar.KernelDensityGen in package randvar
.
<div class="SSJ-bigskip"></div>
|
static |
Given the empirical distribution dist
, this method computes the kernel density estimate at each of the \(m\) evaluation points evalPoints[
\(j\)]
, \(j= 0, 1, …, (m-1)\), where \(m\) is the length of EvalPoints
, the kernel is kern.density(x)
, and the bandwidth is \(h\).
Returns the estimates as an array of \(m\) values. Note that the evaluation points do not have to cover the entire support of the density; they can cover only a small a small interval.
One way to choose \(h\) is via the method getBaseBandwidth(dist) in package randvar
.
void evalDensity | ( | double | data[], |
ContinuousDistribution | kern, | ||
double | h, | ||
double [] | evalPoints, | ||
double [] | density, | ||
double | epsilon0 | ||
) |
Similar to \(computeDensity (dist, kern, h, evalPoints)\), but much more efficient for very large n.
We assume that the kernel is unimodal (increasing, then decreasing). For each evaluation point j, in the sum that defines the density estimator, we add only the terms that contribute more than epsilon0 to the sum. We stop adding as soon as the new term is < epsilon0. One can try epsilon0 = E-10 for example. We have also replaced dist by a sorted array \(double[] data\) that contains the raw data.