SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ConditionalDensityEstimator.java
1package umontreal.ssj.stat.density;
2
27
29
30 @Override
31 public void setData(double[][] data) {
32 this.data = new double[data.length][];
33 for (int i = 0; i < data.length; i++) {
34 this.data[i] = new double[data[i].length];
35 for (int j = 0; j < data[i].length; j++)
36 this.data[i][j] = data[i][j];
37 }
38
39 }
40
41 @Override
42 public double evalDensity(double x) {
43 double dens = 0.0;
44 int N = data.length;
45 double Ninv = 1.0 / (double) N;
46 for (int i = 0; i < N; i++) {
47 dens += evalEstimator(x, data[i]);
48 }
49 dens *= Ninv;
50 return dens;
51 }
52
53 @Override
54 public double[] evalDensity(double[] x) {
55 int k = x.length;
56 double[] dens = new double[k];
57 int N = data.length;
58 double Ninv = 1.0 / (double) N;
59 for (int j = 0; j < k; j++) {
60 dens[j] = 0.0;
61 for (int i = 0; i < N; i++) {
62 dens[j] += evalEstimator(x[j], data[i]);
63
64 }
65 dens[j] *= Ninv;
66 }
67 return dens;
68 }
69
70 @Override
71 public double[] evalDensity(double[] evalPoints, double[][] data) {
73 return evalDensity(evalPoints);
74 }
75
84 public abstract double evalEstimator(double x, double[] data);
85
86 @Override
87 public String toString() {
88 return "Conditional Density Estimator";
89 }
90
91}
This is an abstract class that implements an DensityEstimatorDoubleArray.
double[] evalDensity(double[] evalPoints, double[][] data)
Sets the observations for the density estimator to data and evaluates the density at each point in ev...
String toString()
Gives a short description of the estimator.
void setData(double[][] data)
Sets the observations for the density estimator to data.
double evalDensity(double x)
Evaluates the density estimator at x.
abstract double evalEstimator(double x, double[] data)
Evaluates the function at the point x and the realization of given in the -dimensional array data.
double[] evalDensity(double[] x)
Evaluates the density estimator at the points in evalPoints.
Same as DensityEstimator but here the observations of the underlying model are -dimensional.
double[][] data
The data associated with this DensityEstimatorDoubleArray object, if any.