This class provides methods to construct a kernel density estimator (KDE) for univariate densities from a set of \(n\) individual observations \(x_0,\dots, x_{n-1}\), and to evaluate it at a single point or at a set of selected evaluation points. More...
Public Member Functions | |
| DEKernelDensity (double[] data) | |
| Constructs a KDE from the observations data. | |
| DEKernelDensity (ContinuousDistribution kernel) | |
| Constructs a KDE with the kernel function kernel. | |
| DEKernelDensity (ContinuousDistribution kernel, double[] data) | |
| Constructs a KDE with the kernel function kernel from the observations in data. | |
| DEKernelDensity (double h) | |
| Constructs a KDE with bandwidth \(h\). | |
| DEKernelDensity (double h, double[] data) | |
| Constructs a KDE with bandwidth h from the observations data. | |
| DEKernelDensity (ContinuousDistribution kernel, double h) | |
| Constructs a KDE with the kernel function kernel and bandwidth h. | |
| DEKernelDensity (ContinuousDistribution kernel, double h, double[] data) | |
| Constructs a KDE with the kernel function kernel and bandwidth h from the observations data. | |
| void | setData (double[] data) |
| Sets a new set of observations. | |
| void | setH (double h) |
| Sets the bandwidth to h. | |
| double | getH () |
| Gives the bandwidth \(h\). | |
| ContinuousDistribution | getKernel () |
| Gives the kernel density function \(K\). | |
| void | setKernel (ContinuousDistribution kernel) |
| Sets the kernel density function to kernel. | |
| double | getEps () |
| Gives the threshold-level \(\varepsilon\) for the evaluation of the density. | |
| void | setEps (double eps) |
| Sets the threshold-level \(\varepsilon\) for the evaluation of the density to eps. | |
| double | evalDensity (double x) |
| Evaluates the KDE at the evaluation point x. | |
| double[] | evalDensity (double[] evalPoints) |
| Evaluates the KDE at each of the evaluation points evalPoints and returns the results in an array. | |
| String | toString () |
Gives a short description of the estimator.
| |
| Public Member Functions inherited from umontreal.ssj.stat.density.DensityEstimator | |
| double[] | getData () |
| Gives the observations for this density estimator, if any. | |
| double[] | evalDensity (double[] evalPoints, double[] data) |
| Sets the observations for the density estimator to data and evaluates the density at each point in evalPoints. | |
| double[][] | evalDensity (double[] evalPoints, double[][] data) |
| This method is particularly designed to evaluate the density estimator in such a way that the result can be easily used to estimate the empirical IV and other convergence-related quantities. | |
Static Public Member Functions | |
| static double | evalDensity (double x, ContinuousDistribution kernel, double h, double[] data, double eps) |
| Evaluates the KDE with kernel density functionkernel, bandwidth h which is defined by the observations data at the evaluation point x. | |
| static double[] | evalDensity (double[] evalPoints, ContinuousDistribution kernel, double h, double[] data, double eps) |
| Evaluates the KDE with kernel density functionkernel, bandwidth h which is defined by the observations data at each of the evaluation points evalPoints and returns the results in an array. | |
| static double[][] | evalDensity (double[] evalPoints, ContinuousDistribution kernel, double h, double[][] data, double eps) |
| Assume that we have \(m\) independent realizations of the underlying model. | |
| Static Public Member Functions inherited from umontreal.ssj.stat.density.DensityEstimator | |
| static void | evalDensity (ArrayList< DensityEstimator > listDE, double[] evalPoints, double[][] data, ArrayList< double[][]> listDensity) |
| This function is particularly designed for experiments with many different types of density estimators, as it evaluates all of these estimators at the points in evalPoints. | |
| static double[] | computeVariance (double[][] density) |
| This method computes the empirical variance based on the values given in data. | |
| static double | computeIV (double[][] density, double a, double b, double[] variance) |
| This method estimates the empirical IV over the interval \([a,b]\). | |
| static void | computeIV (ArrayList< double[][]> listDensity, double a, double b, ArrayList< Double > listIV) |
| This method estimates the empirical IV over the interval \([a,b]\) for a collection of different estimators. | |
| static double[] | computeMISE (ContinuousDistribution dist, double[] evalPoints, double[][] density, double a, double b, double[] variance, double[] sqBias, double[] mse) |
| In situations where the true density is known this method can estimate the empirical MISE over the interval \([a,b]\). | |
| static void | computeMISE (ContinuousDistribution dist, double[] evalPoints, ArrayList< double[][]> listDensity, double a, double b, ArrayList< double[]> listMISE) |
| This method estimates the empirical MISE over the interval \([a,b]\) for a collection of different estimators. | |
| static String | plotDensity (double[] evalPoints, double[] density, String plotTitle, String[] axisTitles) |
| Gives a plot of the estimated density. | |
| static double | roughnessFunctional (double[] density, double a, double b) |
| Estimates the roughness functional. | |
Additional Inherited Members | |
| Protected Attributes inherited from umontreal.ssj.stat.density.DensityEstimator | |
| double[] | data |
| The data associated with this DensityEstimator object, if any. | |
This class provides methods to construct a kernel density estimator (KDE) for univariate densities from a set of \(n\) individual observations \(x_0,\dots, x_{n-1}\), and to evaluate it at a single point or at a set of selected evaluation points.
The observations can be collected data or realizations of a umontreal.ssj.mcqmctools.MonteCarloModelDouble, for instance.
The KDE takes a fixed bandwidth \( h>0\) as well as a kernel function \(k\), which is also referred to as kernel density. The kernel density should be non-negative and integrate to one. For \(x\in[a,b]\), the KDE itself is defined as
\[ \hat{f}_{n}(x) = \hat{f}_{n,h}(x) = \frac{1}{nh} \sum_{i = 0}^{n-1} k\left( \frac{x - x_i}{h} \right). \tag{KDE} \]
This class also offers static methods so that the user can simply evaluate the density based on a set of observations without having to construct a KDE.
Definition at line 28 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | double[] | data | ) |
Constructs a KDE from the observations data.
| data | the observations. |
Definition at line 52 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | ContinuousDistribution | kernel | ) |
Constructs a KDE with the kernel function kernel.
| kernel | the kernel density function. |
Definition at line 61 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | ContinuousDistribution | kernel, |
| double[] | data ) |
Constructs a KDE with the kernel function kernel from the observations in data.
| kernel | the kernel density function. |
| data | the observations. |
Definition at line 72 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | double | h | ) |
Constructs a KDE with bandwidth \(h\).
| h | the bandwidth. |
Definition at line 82 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | double | h, |
| double[] | data ) |
Constructs a KDE with bandwidth h from the observations data.
| h | the bandwidth |
| data | the observations |
Definition at line 92 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | ContinuousDistribution | kernel, |
| double | h ) |
Constructs a KDE with the kernel function kernel and bandwidth h.
| kernel | the kernel density function |
| h | the bandwidth |
Definition at line 103 of file DEKernelDensity.java.
| umontreal.ssj.stat.density.DEKernelDensity.DEKernelDensity | ( | ContinuousDistribution | kernel, |
| double | h, | ||
| double[] | data ) |
Constructs a KDE with the kernel function kernel and bandwidth h from the observations data.
| kernel | the kernel density function |
| h | the bandwidth |
| data | the observations |
Definition at line 116 of file DEKernelDensity.java.
| double umontreal.ssj.stat.density.DEKernelDensity.evalDensity | ( | double | x | ) |
Evaluates the KDE at the evaluation point x.
Each summand w.r.t. \(i\) in ( KDE ) is only considered if it is larger than \(\varepsilon\) . For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing.
| x | the evaluation point. |
Reimplemented from umontreal.ssj.stat.density.DensityEstimator.
Definition at line 199 of file DEKernelDensity.java.
|
static |
Evaluates the KDE with kernel density functionkernel, bandwidth h which is defined by the observations data at the evaluation point x.
Each summand w.r.t. \(i\) in ( KDE ) is only considered if it is larger than eps . For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing.
| x | the evaluation point. |
| kernel | the kernel density function. |
| h | the bandwidth. |
| data | the observations. |
| eps | the threshold level. |
Definition at line 292 of file DEKernelDensity.java.
| double[] umontreal.ssj.stat.density.DEKernelDensity.evalDensity | ( | double[] | evalPoints | ) |
Evaluates the KDE at each of the evaluation points evalPoints and returns the results in an array.
Each summand w.r.t. \(i\) in ( KDE ) is only considered if it is larger than \(\varepsilon\) .
For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing, and that the points in evalPoints are sorted in increasing order. This allows this method to avoid looping over all \(i\) for each evaluation point by remembering that some summands have already been deemed too small.
| evalPoints | the evaluation points. |
Reimplemented from umontreal.ssj.stat.density.DensityEstimator.
Definition at line 239 of file DEKernelDensity.java.
|
static |
Evaluates the KDE with kernel density functionkernel, bandwidth h which is defined by the observations data at each of the evaluation points evalPoints and returns the results in an array.
Each summand w.r.t. \(i\) in ( KDE ) is only considered if it is larger than \(\varepsilon\) .
For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing, and that the points in evalPoints are sorted in increasing order. This allows this method to avoid looping over all \(i\) for each evaluation point by remembering that some summands have already been deemed too small.
| evalPoints | the evaluation points. |
| kernel | the kernel density function. |
| h | the bandwidth. |
| data | the observations. |
| eps | the threshold level. |
Definition at line 339 of file DEKernelDensity.java.
|
static |
Assume that we have \(m\) independent realizations of the underlying model.
For each such realization this method evaluates a KDE with kernel density functionkernel, bandwidth h at the points from evalPoints. The independent realizations are passed via the 2-dimensional \(m\times n\) array data, where \(n\) denotes the number of observations per realization. Hence, its first index identifies the independent realization while its second index identifies a specific observation of this realization.
The result is returned as a \(m\times k\) matrix, where \(k \) is the number of evaluation points, i.e., the length of evalPoints. The first index, again, identifies the independent realization whereas the second index corresponds to the point of evalPoints at which the KDE was evaluated.
For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing, and that the points in evalPoints are sorted in increasing order. For a specific observation, this allows this method to avoid looping over all \(i\) for each evaluation point by remembering that some summands have already been deemed too small.
| evalPoints | the evaluation points. |
| kernel | the kernel density function. |
| h | the bandwidth. |
| data | the two-dimensional array of observations. |
| eps | the threshold level. |
Definition at line 394 of file DEKernelDensity.java.
| double umontreal.ssj.stat.density.DEKernelDensity.getEps | ( | ) |
Gives the threshold-level \(\varepsilon\) for the evaluation of the density.
Summands w.r.t. \(i\) in ( KDE ) smaller than this value are considered negligible.
Definition at line 174 of file DEKernelDensity.java.
| double umontreal.ssj.stat.density.DEKernelDensity.getH | ( | ) |
Gives the bandwidth \(h\).
Definition at line 144 of file DEKernelDensity.java.
| ContinuousDistribution umontreal.ssj.stat.density.DEKernelDensity.getKernel | ( | ) |
Gives the kernel density function \(K\).
Definition at line 153 of file DEKernelDensity.java.
| void umontreal.ssj.stat.density.DEKernelDensity.setData | ( | double[] | data | ) |
Sets a new set of observations.
| data | the desired observations. |
Reimplemented from umontreal.ssj.stat.density.DensityEstimator.
Definition at line 126 of file DEKernelDensity.java.
| void umontreal.ssj.stat.density.DEKernelDensity.setEps | ( | double | eps | ) |
Sets the threshold-level \(\varepsilon\) for the evaluation of the density to eps.
Summands w.r.t. \(i\) in ( KDE ) smaller than this value are considered negligible.
| eps | the threshold-level for evaluation. |
Definition at line 186 of file DEKernelDensity.java.
| void umontreal.ssj.stat.density.DEKernelDensity.setH | ( | double | h | ) |
Sets the bandwidth to h.
| h | the desired bandwidth. |
Definition at line 135 of file DEKernelDensity.java.
| void umontreal.ssj.stat.density.DEKernelDensity.setKernel | ( | ContinuousDistribution | kernel | ) |
Sets the kernel density function to kernel.
| kernel | the kernel density function to be used. |
Definition at line 162 of file DEKernelDensity.java.
| String umontreal.ssj.stat.density.DEKernelDensity.toString | ( | ) |
Gives a short description of the estimator.
Reimplemented from umontreal.ssj.stat.density.DensityEstimator.
Definition at line 270 of file DEKernelDensity.java.