SSJ  3.2.1
Stochastic Simulation in Java
Public Member Functions | List of all members
DEKernelDensity Class Reference

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...

Inheritance diagram for DEKernelDensity:
[legend]
Collaboration diagram for DEKernelDensity:
[legend]

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 ()
 
- Public Member Functions inherited from DensityEstimator
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 Public Member Functions inherited from DensityEstimator
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 Protected Member Functions inherited from DensityEstimator
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...
 
- Protected Attributes inherited from DensityEstimator
double [] data
 The data associated with this DensityEstimator object, if any.
 

Detailed Description

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} \]

Author
puchhamf

Constructor & Destructor Documentation

◆ DEKernelDensity() [1/4]

Constructs a KDE with the kernel function kernel.

Parameters
kernelthe kernel density function.

◆ DEKernelDensity() [2/4]

DEKernelDensity ( double  h)

Constructs a KDE with bandwidth \(h\).

Parameters
hthe bandwidth.

◆ DEKernelDensity() [3/4]

DEKernelDensity ( ContinuousDistribution  kernel,
double  h 
)

Constructs a KDE with the kernel function kernel and bandwidth h.

Parameters
kernelthe kernel density function
hthe bandwidth

◆ DEKernelDensity() [4/4]

DEKernelDensity ( ContinuousDistribution  kernel,
double  h,
double []  data 
)

Constructs a KDE with the kernel function kernel and bandwidth h.

Parameters
kernelthe kernel density function
hthe bandwidth

Member Function Documentation

◆ evalDensity() [1/2]

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.

Parameters
xthe evaluation point.
datathe observations of the underlying model.
Returns
the value of the KDE at x.

◆ evalDensity() [2/2]

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.

Parameters
evalPointsthe evaluation points.
datathe observations of the underlying model.
Returns
the value of the KDE at evalPoints.

◆ getEps()

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.

Returns
the threshold-level for evaluation.

◆ getH()

double getH ( )

Gives the bandwidth \(h\).

Returns
the bandwidth.

◆ getKernel()

ContinuousDistribution getKernel ( )

Gives the kernel density function \(K\).

Returns
the kernel density function.

◆ setEps()

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.

Parameters
epsthe threshold-level for evaluation.

◆ setH()

void setH ( double  h)

Sets the bandwidth to h.

Parameters
hthe desired bandwidth.

◆ setKernel()

void setKernel ( ContinuousDistribution  kernel)

Sets the kernel density function to kernel.

Parameters
kernelthe kernel density function to be used.

The documentation for this class was generated from the following file: