SSJ
3.2.1
Stochastic Simulation in Java
|
This class provides methods to construct a kernel density estimator (KDE) for univariate densities from a set of \(n\) individual observations \(X_0, …, X_{n-1}\), and to evaluate it at a single point or at a set of selected evaluation points. More...
Public Member Functions | |
DEKernelDensity (ContinuousDistribution kernel) | |
Constructs a KDE with the kernel function kernel. More... | |
DEKernelDensity (double h) | |
Constructs a KDE with bandwidth \(h\). More... | |
DEKernelDensity (ContinuousDistribution kernel, double h) | |
Constructs a KDE with the kernel function kernel and bandwidth h. More... | |
DEKernelDensity (ContinuousDistribution kernel, double h, double[] data) | |
Constructs a KDE with the kernel function kernel and bandwidth h. More... | |
void | setH (double h) |
Sets the bandwidth to h. More... | |
double | getH () |
Gives the bandwidth \(h\). More... | |
ContinuousDistribution | getKernel () |
Gives the kernel density function \(K\). More... | |
void | setKernel (ContinuousDistribution kernel) |
Sets the kernel density function to kernel. More... | |
double | getEps () |
Gives the threshold-level \(\varepsilon\) for the evaluation of the density. More... | |
void | setEps (double eps) |
Sets the threshold-level \(\varepsilon\) for the evaluation of the density to eps. More... | |
double | evalDensity (double x, double[] data) |
Evaluates the KDE defined by the observations data at the evaluation point x. More... | |
double | evalDensity (double x, double[] data, double a, double b) |
Same as #evalDensity(double, double[]) but with two placeholder arguments to implement the corresponding function demanded by the abstract superclass umontreal.ssj.stat.density.DensityEstimator. | |
double [] | evalDensity (double[] evalPoints, double[] data) |
Evaluates the KDE defined by the observations data at each of the evaluation points evalPoints and returns the results in an array. More... | |
String | toString () |
![]() | |
abstract double | evalDensity (double x, double data[], double a, double b) |
Constructs a density estimator over the interval \([a,b]\) based on the observations data if necessary, and evaluates it at x. More... | |
double [] | evalDensity (double[] evalPoints, double[] data, double a, double b) |
Constructs a density estimator over the interval \([a,b]\) based on the observations data if necessary, and evaluates it at the points in evalPoints. More... | |
double [][] | evalDensity (double[] evalPoints, double[][] data, double a, double b) |
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. More... | |
abstract String | toString () |
Gives a short description of the estimator. More... | |
Additional Inherited Members | |
![]() | |
static void | evalDensity (ArrayList< DensityEstimator > listDE, double[] evalPoints, double[][] data, double a, double b, 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. More... | |
static double [] | computeVariance (double[][] density) |
This method computes the empirical variance based on the values given in data. More... | |
static double | computeIV (double[][] density, double a, double b, double[] variance) |
This method estimates the empirical IV over the interval \([a,b]\). More... | |
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. More... | |
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]\). More... | |
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. More... | |
static String | plotDensity (double[] evalPoints, double[] density, String plotTitle, String[] axisTitles) |
Gives a plot of the estimated density. More... | |
static double | roughnessFunctional (double[] density, double a, double b) |
Estimates the roughness functional. More... | |
![]() | |
static double | coefficientOfDetermination (double[] data, double[] dataEstimated) |
Computes the Coefficient of determination \(R^2\) of the observed data data and the estimated data dataEstimated. More... | |
![]() | |
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, …, X_{n-1}\), and to evaluate it at a single point or at a set of selected evaluation points.
The observations can be 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} \]
DEKernelDensity | ( | ContinuousDistribution | kernel | ) |
Constructs a KDE with the kernel function kernel.
kernel | the kernel density function. |
DEKernelDensity | ( | double | h | ) |
Constructs a KDE with bandwidth \(h\).
h | the bandwidth. |
DEKernelDensity | ( | ContinuousDistribution | kernel, |
double | h | ||
) |
Constructs a KDE with the kernel function kernel and bandwidth h.
kernel | the kernel density function |
h | the bandwidth |
DEKernelDensity | ( | ContinuousDistribution | kernel, |
double | h, | ||
double [] | data | ||
) |
Constructs a KDE with the kernel function kernel and bandwidth h.
kernel | the kernel density function |
h | the bandwidth |
double evalDensity | ( | double | x, |
double [] | data | ||
) |
Evaluates the KDE 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 \(\varepsilon\) . For this method the kernel function \(K\) is assumed to be unimodal, i.e. increasing and then decreasing.
x | the evaluation point. |
data | the observations of the underlying model. |
double [] evalDensity | ( | double [] | evalPoints, |
double [] | data | ||
) |
Evaluates the KDE 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. |
data | the observations of the underlying model. |
double 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.
double getH | ( | ) |
Gives the bandwidth \(h\).
ContinuousDistribution getKernel | ( | ) |
Gives the kernel density function \(K\).
void 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. |
void setH | ( | double | h | ) |
Sets the bandwidth to h.
h | the desired bandwidth. |
void setKernel | ( | ContinuousDistribution | kernel | ) |
Sets the kernel density function to kernel.
kernel | the kernel density function to be used. |