SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.stat.density.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 umontreal.ssj.stat.density.DensityDerivativeEstimator:
umontreal.ssj.stat.density.DensityEstimator umontreal.ssj.stat.density.DEDerivativeGaussian

Public Member Functions

int getOrder ()
 Gives the order \(r\) of the DDE.
void setOrder (int order)
 Sets the order \(r\) of the DDE to order.
double getH ()
 Gives the current bandwidth \(h\).
void setH (double h)
 Sets the bandwidth \(h\) to h.
void setData (double[] data)
 Sets the observations for the density estimator do data.Note that, in some cases, this requires to completely reconstruct the density estimator.
Parameters
datathe desired observations.

String toString ()
 Gives a short description of the estimator.
Returns
a short description.

Public Member Functions inherited from umontreal.ssj.stat.density.DensityEstimator
double[] getData ()
 Gives the observations for this density estimator, if any.
abstract double evalDensity (double x)
 Evaluates the density estimator at x.
double[] evalDensity (double[] evalPoints)
 Evaluates the density estimator at the points in evalPoints.
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 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\).
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\).
static double densityFunctionalGaussian (int r, double sigma)
 Computes \(\Phi_{2r}(p)\), i.e.
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.

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 [199])

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

    So, in order to obtain a good estimate for \f$f^{(r)} \f$ one
    requires a good estimate for \f$f^{(r+2)}\f$. A way to break out of
    this cyclic argument is to resort to taking a reasonably good
    estimate for \f$f^{(r+2)}\f$ 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$ f
    \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
    \f$x_0,x_1,\dots,x_{n-1}\f$ and for which the roughness functional
    \f$R(p^{(r+2)})\f$ (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$f^{(r+2t)} \f$ and iterate
    ({@link REF_stat_density_DensityDerivativeEstimator_hopt hopt})
    \f$t\f$ times. The function `hAmiseR(int, int, double, double[],
    double, DensityDerivativeEstimator, double[], double[], double,
    double)` implements this recursion.

    Since the above methods to compute \f$h_{\text{AMISE}}^{(r)}\f$ 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$f^{(r)}\f$ can also be expressed in terms of
    \f$\Phi_{2r}(f)\f$, the so-called density functional of even order
    \f$2r \f$ , i.e.

    \f[\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). \f]

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

Definition at line 70 of file DensityDerivativeEstimator.java.

Member Function Documentation

◆ densityFunctionalGaussian()

double umontreal.ssj.stat.density.DensityDerivativeEstimator.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\).

Definition at line 219 of file DensityDerivativeEstimator.java.

◆ getH()

double umontreal.ssj.stat.density.DensityDerivativeEstimator.getH ( )

Gives the current bandwidth \(h\).

Returns
the bandwidth.

Definition at line 101 of file DensityDerivativeEstimator.java.

◆ getOrder()

int umontreal.ssj.stat.density.DensityDerivativeEstimator.getOrder ( )

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

Returns
the order of the DDE.

Definition at line 83 of file DensityDerivativeEstimator.java.

◆ hAmiseR() [1/2]

double umontreal.ssj.stat.density.DensityDerivativeEstimator.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.

Definition at line 137 of file DensityDerivativeEstimator.java.

◆ hAmiseR() [2/2]

double umontreal.ssj.stat.density.DensityDerivativeEstimator.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.

Definition at line 185 of file DensityDerivativeEstimator.java.

◆ setData()

void umontreal.ssj.stat.density.DensityDerivativeEstimator.setData ( double[] data)

Sets the observations for the density estimator do data.Note that, in some cases, this requires to completely reconstruct the density estimator.

Parameters
datathe desired observations.

Reimplemented from umontreal.ssj.stat.density.DensityEstimator.

Definition at line 117 of file DensityDerivativeEstimator.java.

◆ setH()

void umontreal.ssj.stat.density.DensityDerivativeEstimator.setH ( double h)

Sets the bandwidth \(h\) to h.

Parameters
hthe desired bandwidth.

Definition at line 110 of file DensityDerivativeEstimator.java.

◆ setOrder()

void umontreal.ssj.stat.density.DensityDerivativeEstimator.setOrder ( int order)

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

Parameters
orderthe desired order.

Definition at line 92 of file DensityDerivativeEstimator.java.

◆ toString()

String umontreal.ssj.stat.density.DensityDerivativeEstimator.toString ( )

Gives a short description of the estimator.

Returns
a short description.

Reimplemented from umontreal.ssj.stat.density.DensityEstimator.

Reimplemented in umontreal.ssj.stat.density.DEDerivativeGaussian.

Definition at line 235 of file DensityDerivativeEstimator.java.


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