SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Static Public Member Functions | List of all members
DensityDerivativeEstimator Class Referenceabstract

This class implements a density derivative estimator (DDE) based on a kernel density estimator (KDE) with a sufficiently smooth kernel function \(k\), see umontreal.ssj.stat.density.DEKernelDensity. More...

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

Public Member Functions

int getOrder ()
 Gives the order \(r\) of the DDE. More...
 
void setOrder (int order)
 Sets the order \(r\) of the DDE to order. More...
 
double getH ()
 Gives the current bandwidth \(h\). More...
 
void setH (double h)
 Sets the bandwidth \(h\) to h. More...
 
void setData (double[] data)
 
String toString ()
 
- Public Member Functions inherited from DensityEstimator
abstract void setData (double[] data)
 Sets the observations for the density estimator do data. More...
 
double [] getData ()
 Gives the observations for this density estimator, if any. More...
 
abstract double evalDensity (double x)
 Evaluates the density estimator at x. More...
 
double [] evalDensity (double[] evalPoints)
 Evaluates the density estimator at the points in evalPoints. More...
 
double [] evalDensity (double[] evalPoints, double[] data)
 Sets the observations for the density estimator to data and evaluates the density at each point in evalPoints. More...
 
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. More...
 
abstract String toString ()
 Gives a short description of the estimator. More...
 

Static Public Member Functions

static double hAmiseR (int r, double mu2, double mu2Derivative, double init, int n)
 Given a value init for the roughness functional of \( f^{(r+2)}\), mu2 the second moment of the kernel function \(K\), and mu2Derivative the second moment of \(K^{(r)}\), this method computes the asymptotically optimal bandwidth for the DDE based on \(n\) observations simulated by Monte Carlo for the \(r\)-th derivative of the sought density \(f\). More...
 
static double hAmiseR (int r, int t, double mu2, double[] mu2Derivative, double init, DensityDerivativeEstimator dde, double[] evalPoints, double a, double b)
 Given an estimate of \(R(f^{(r+2t)})\) via init as initial value, this function iterates over (hopt) \(t\) times to obtain the asymptotically optimal bandwidth for the DDE based on \(n\) observations simulated by Monte Carlo for the \(r\)-th derivative of the sought density \(f\). More...
 
static double densityFunctionalGaussian (int r, double sigma)
 Computes \(\Phi_{2r}(p)\), i.e. More...
 
- Static Public Member Functions inherited from 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. 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...
 

Additional Inherited Members

- Protected Attributes inherited from DensityEstimator
double [] data
 The data associated with this DensityEstimator object, if any.
 

Detailed Description

This class implements a density derivative estimator (DDE) based on a kernel density estimator (KDE) with a sufficiently smooth kernel function \(k\), see umontreal.ssj.stat.density.DEKernelDensity.

Such an estimator is used to find the \(r\)-th derivative of an unknown density based on \(n\) observations \(x_0,x_1,\dots,x_{n-1} \) of an underlying model. It is of the form

\[ \hat{f}^{(r)}_n(x) = \hat{f}^{(r)}_{n,h}(x)=\frac{1}{n h^{r + 1}} \sum_{i = 0}^{n - 1} k^{(r)}\left( \frac{x - x_i}{h} \right), \]

where \(h\) denotes the bandwidth. So, as a matter of fact, it is the \(r\)-th derivative of a KDE. This class provides basic tools to construct and evaluate DDEs. Note that sufficient smoothness of the kernel function \(K\) as well as of the unknown density \(f\) is required.

Moreover, for observations gained from a Monte Carlo simulation, the asymptotically optimal (w.r.t. the mean integrated square error) bandwidth \( h_{\text{AMISE}}^{(r)} \) can be computed explicitely via the formula (see [206])

\[ h_{\text{AMISE}}^{(r)} = \left[ \frac{\mu_2(k^{(r)}) (2r+1)}{\mu^2_2(k) R(f^{(r+2)})n} \right]^{1/(2r+5)},\tag{hopt} \]

So, in order to obtain a good estimate for \(f^{(r)} \) one requires a good estimate for \(f^{(r+2)}\). A way to break out of this cyclic argument is to resort to taking a reasonably good estimate for \(f^{(r+2)}\) as initial value. This is implemented as hAmiseR(int, double, double, double, int). To obtain such a reasonable initial value, one can, for instance, assume that \( f \) belongs to a known family of distributions (e.g. normal distributions), such that its defining parameters (e.g. mean, standard deviation) can be estimated from the observations \(X_0,X_1,\dots,X_{n-1}\) and for which the roughness functional \(R(p^{(r+2)})\) (see umontreal.ssj.stat.density.DensityEstimator::roughnessFunctional(double[], double, double) ) can be easily estimated or even computed analytically.

Certainly, one can also try obtain a good approximation of \(f^{(r+2t)} \) and iterate (hopt) \(t\) times. The function hAmiseR(int, int, double, double[], double, DensityDerivativeEstimator, double[], double[], double, double) implements this recursion.

Since the above methods to compute \(h_{\text{AMISE}}^{(r)}\) rely on initial values for the second moments of derivatives of the unknown density, it is probably worth mentioning that the second moment of \(f^{(r)}\) can also be expressed in terms of \(\Phi_{2r}(f)\), the so-called density functional of even order \(2r \) , i.e.

\[\mu_2(f^{(r)}) = (-1)^r \int_{-\infty}^{\infty} f^{(2r)}(x)f(x)\mathrm{d}x = (-1)^r \mathbb{E}[f^{(2r)}] = \Phi_{2r}(f). \]

For such an initial value, one could, for instance, assume that the target density is a normal distribution with standard deviation \(\sigma\). To this end, we include the method densityFunctionalGaussian(int, double).

Member Function Documentation

◆ densityFunctionalGaussian()

static double densityFunctionalGaussian ( int  r,
double  sigma 
)
static

Computes \(\Phi_{2r}(p)\), i.e.

the density functional of order \(2r\) of a normal density \(p\) with standard deviation sigma,

\[\Phi_{2r}(p) = \int_{-\infty}^{\infty} p^{(2r)}(x) p(x)\mathrm{d}x\]

and it can be comuted as

\[\Phi_{2r}(p) = \frac{(-1)^r (2r)!}{(2\sigma)^{2r+1} r! \sqrt{\pi}}. \]

Parameters
rthe order of the functional. Has to be even.
sigmathe standard deviation of the normal density considered.
Returns
the density functional of order \(2r\).

◆ getH()

double getH ( )

Gives the current bandwidth \(h\).

Returns
the bandwidth.

◆ getOrder()

int getOrder ( )

Gives the order \(r\) of the DDE.

Returns
the order of the DDE.

◆ hAmiseR() [1/2]

static double hAmiseR ( int  r,
double  mu2,
double  mu2Derivative,
double  init,
int  n 
)
static

Given a value init for the roughness functional of \( f^{(r+2)}\), mu2 the second moment of the kernel function \(K\), and mu2Derivative the second moment of \(K^{(r)}\), this method computes the asymptotically optimal bandwidth for the DDE based on \(n\) observations simulated by Monte Carlo for the \(r\)-th derivative of the sought density \(f\).

Parameters
rthe order of the sought derivative.
mu2the second moment of \(K\).
mu2Derivativethe second moment of \(K^{(r)}\).
initestimate of the roughness functional of the \((r+2)\)-th derivative of the density
nthe number of observations.
Returns
the asymptotically optimal bandwidth for the DDE of the \(r\)-th derivative of the unknown density.

◆ hAmiseR() [2/2]

static double hAmiseR ( int  r,
int  t,
double  mu2,
double []  mu2Derivative,
double  init,
DensityDerivativeEstimator  dde,
double []  evalPoints,
double  a,
double  b 
)
static

Given an estimate of \(R(f^{(r+2t)})\) via init as initial value, this function iterates over (hopt) \(t\) times to obtain the asymptotically optimal bandwidth for the DDE based on \(n\) observations simulated by Monte Carlo for the \(r\)-th derivative of the sought density \(f\).

Each recursion step calls hAmiseR(int, double, double, double, int). The thereby obtained bandwidth can be used for estimating the density in the next step. The new initial value for the function call is computed by estimating the roughness functional of the corresponding derivative by umontreal.ssj.stat.density.DensityEstimator.roughnessFunctional(double[], double, double) over \([a,b]\) with the quadrature points evalPoints.

The second moments of the derivatives of the ernel function \(\mu_2\left(K^{(r+2(t-1))}\right), \mu_2\left(K^{r+2(t-2)}\right),\dots,\mu_2\left(K^{(r)}\right)\) are passed in the array mu2Derivative of length \(t\) in exactly this order.

Note that the kernel function and the density have to be at least \((r+2(t-1))\) times and \((r+2t)\) times differentiable, respectively, to make use of this method.

Parameters
rthe order of the sought derivative.
tthe number of iteration steps.
mu2the second moment of the kernel function.
mu2Derivativethe second moments of the derivatives of the kernel function.
initthe estimate of the roughness functional of the \((r+2t)\)-th derivative of the sought density.
ddethe DDE used for estimating the bandwidth.
evalPointsthe quadrature points used for estimating the roughness functionals
athe left boundary of the interval considered.
bthe right boundary of the interval considered.
Returns
the asymptotically optimal bandwidth for the DDE of the \(r\)-th derivative of the unknown.

◆ setH()

void setH ( double  h)

Sets the bandwidth \(h\) to h.

Parameters
hthe desired bandwidth.

◆ setOrder()

void setOrder ( int  order)

Sets the order \(r\) of the DDE to order.

Parameters
orderthe desired order.

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