SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DensityDerivativeEstimator.java
1package umontreal.ssj.stat.density;
2
70public abstract class DensityDerivativeEstimator extends DensityEstimator {
71
73 private int order;
74
76 private double h;
77
83 public int getOrder() {
84 return order;
85 }
86
92 public void setOrder(int order) {
93 this.order = order;
94 }
95
101 public double getH() {
102 return h;
103 }
104
110 public void setH(double h) {
111 this.h = h;
112 }
113
117 public void setData(double[] data) {
118 this.data = data;
119 }
120
137 public static double hAmiseR(int r, double mu2, double mu2Derivative, double init, int n) {
138 double invN = 1.0 / (double) n;
139 double sign = r % 2 == 0 ? 1.0 : -1.0;
140 double h = sign * mu2Derivative * (2.0 * (double) r + 1.0) * invN / (mu2 * init);
141 double exp = 1.0 / (2.0 * (double) r + 5.0);
142 return Math.pow(h, exp);
143 }
144
184
185 public static double hAmiseR(int r, int t, double mu2, double[] mu2Derivative, double init,
186 DensityDerivativeEstimator dde, double[] evalPoints, double a, double b) {
187 double h;
188 int k = evalPoints.length;
189 double[] estDensity = new double[k];
190 int n = dde.data.length;
191
192 for (int tau = t - 1; tau >= 1; tau--) {
193 h = hAmiseR(r + 2 * tau, mu2, mu2Derivative[tau], init, n);
194 dde.setH(h);
195 dde.setOrder(r + 2 * tau);
196 estDensity = dde.evalDensity(evalPoints);
197 init = roughnessFunctional(estDensity, a, b);
198 }
199
200 return hAmiseR(r, mu2, mu2Derivative[0], init, n);
201 }
202
218 // TODO: look for formulas with odd r.
219 public static double densityFunctionalGaussian(int r, double sigma) {
220 double sign = (r % 2 == 0 ? 1.0 : -1.0);
221 double facTerm = 1.0;
222 for (int i = r + 1; i <= 2 * r; i++) {
223 facTerm *= (double) i;
224 }
225 double denom = Math.pow(2.0 * sigma, (double) (2.0 * r + 1.0));
226
227 denom *= Math.sqrt(Math.PI);
228
229 return sign * facTerm / denom;
230 }
231
235 public String toString() {
236 return "DDE [h = " + h + "]";
237 }
238}
This class implements a density derivative estimator (DDE) based on a kernel density estimator (KDE) ...
static double hAmiseR(int r, double mu2, double mu2Derivative, double init, int n)
Given a value init for the roughness functional of , mu2 the second moment of the kernel function ,...
String toString()
Gives a short description of the estimator.a short description.
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 via init as initial value, this function iterates over (hopt) times to obtain ...
void setData(double[] data)
Sets the observations for the density estimator do data.Note that, in some cases, this requires to co...
void setOrder(int order)
Sets the order of the DDE to order.
static double densityFunctionalGaussian(int r, double sigma)
Computes , i.e.
This abstract class represents a univariate density estimator (DE).
double[] data
The data associated with this DensityEstimator object, if any.
static double roughnessFunctional(double[] density, double a, double b)
Estimates the roughness functional.
abstract double evalDensity(double x)
Evaluates the density estimator at x.