2package umontreal.ssj.stat.density;
4import java.util.ArrayList;
5import umontreal.ssj.probdist.ContinuousDistribution;
6import umontreal.ssj.stat.PgfDataTable;
106 int k = evalPoints.length;
107 double[] dens =
new double[k];
108 for (
int j = 0; j < k; j++)
156 double[][]
density =
new double[m][];
157 for (
int r = 0; r < m; r++)
187 public static void evalDensity(ArrayList<DensityEstimator> listDE,
double[] evalPoints,
double[][]
data,
188 ArrayList<
double[][]> listDensity) {
190 listDensity.add(de.evalDensity(evalPoints,
data));
213 double meanDens[] =
new double[k];
214 double varDens[] =
new double[k];
217 for (
int r = 0; r < m; r++) {
219 for (
int j = 0; j < k; j++) {
222 meanDens[j] += y / (double) (r + 1);
223 varDens[j] += y * (x - meanDens[j]);
227 for (
int j = 0; j < k; j++)
228 varDens[j] /= (
double) (m - 1);
272 public static double computeIV(
double[][]
density,
double a,
double b,
double[] variance) {
276 for (
double var : variance)
278 return iv * (b - a) / (
double) k;
306 public static void computeIV(ArrayList<
double[][]> listDensity,
double a,
double b, ArrayList<Double> listIV) {
309 int k = (listDensity.get(0))[0].length;
310 double[] variance =
new double[k];
311 for (
double[][]
density : listDensity) {
366 double b,
double[] variance,
double[] sqBias,
double[] mse) {
368 int k = evalPoints.length;
373 double meanDens[] =
new double[k];
376 for (
int r = 0; r < m; r++) {
379 for (
int j = 0; j < k; j++) {
382 trueDensity = dist.
density(evalPoints[j]);
385 meanDens[j] += y / (double) (r + 1);
386 variance[j] += y * (x - meanDens[j]);
394 for (
int j = 0; j < k; j++) {
395 variance[j] /= (double) (m - 1.0);
396 mse[j] /= (double) m;
397 sqBias[j] = mse[j] - variance[j];
403 double fact = (b - a) / (
double) k;
405 mise *= (b - a) / ((
double) k);
407 double[] res = { iv, mise - iv, mise };
446 double a,
double b, ArrayList<
double[]> listMISE) {
448 int k = evalPoints.length;
452 double[] tmp =
new double[k];
453 for (
double[][]
density : listDensity) {
488 public static String
plotDensity(
double[] evalPoints,
double[]
density, String plotTitle, String[] axisTitles) {
489 double[][] plotData =
new double[evalPoints.length][];
490 for (
int i = 0; i < evalPoints.length; i++) {
491 plotData[i] =
new double[2];
492 plotData[i][0] = evalPoints[i];
496 StringBuffer sb =
new StringBuffer(
"");
500 return sb.toString();
518 double fac = (b - a) / (
double)
density.length;
Classes implementing continuous distributions should inherit from this base class.
abstract double density(double x)
Returns , the density evaluated at .
Represents a data table which has a name, a number of observations (rows), a number of fields (column...
String drawPgfPlotSingleCurve(String title, String axistype, String xaxis, String yaxis, int logbasis, String axisoptions, String plotoptions)
Returns a String that contains a complete tikzpicture for the pgfplot package, showing the field j2 a...
This abstract class represents a univariate density estimator (DE).
static double computeIV(double[][] density, double a, double b, double[] variance)
This method estimates the empirical IV over the interval .
static double[] computeVariance(double[][] density)
This method computes the empirical variance based on the values given in data.
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 estimator...
double[] data
The data associated with this DensityEstimator object, if any.
abstract void setData(double[] data)
Sets the observations for the density estimator do data.
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 in...
static double roughnessFunctional(double[] density, double a, double b)
Estimates the roughness functional.
abstract String toString()
Gives a short description of the estimator.
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 for a collection of different estimators.
double[][] evalDensity(double[] evalPoints, double[][] data)
This method is particularly designed to evaluate the density estimator in such a way that the result ...
static String plotDensity(double[] evalPoints, double[] density, String plotTitle, String[] axisTitles)
Gives a plot of the estimated density.
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 ev...
static void computeIV(ArrayList< double[][]> listDensity, double a, double b, ArrayList< Double > listIV)
This method estimates the empirical IV over the interval for a collection of different estimators.
Tools for univariate density estimation.