SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.probdist.EmpiricalDist Class Reference

Extends DiscreteDistribution to an empirical distribution function, based on the observations \(X_{(1)},…,X_{(n)}\) (sorted by increasing order). More...

Inheritance diagram for umontreal.ssj.probdist.EmpiricalDist:
umontreal.ssj.probdist.DiscreteDistribution umontreal.ssj.probdist.Distribution

Public Member Functions

 EmpiricalDist (double[] obs)
 Constructs a new empirical distribution using all the observations stored in obs, and which are assumed to have been sorted in increasing numerical order.
 EmpiricalDist (Reader in) throws IOException
 Constructs a new empirical distribution using the observations read from the reader in.
double prob (int i)
 Returns \(p_i\), the probability of the \(i\)-th value, for.
double cdf (double x)
double barF (double x)
double inverseF (double u)
double getMean ()
 Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution.
double getStandardDeviation ()
 Computes the standard deviation of the distribution.
double getVariance ()
 Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution.
double getMedian ()
 Returns the median.
int getN ()
 Returns \(n\), the number of observations.
double getObs (int i)
 Returns the value of \(X_{(i)}\), for \(i=0, 1, …, n-1\).
double getSampleMean ()
 Returns the sample mean of the observations.
double getSampleVariance ()
 Returns the sample variance of the observations.
double getSampleStandardDeviation ()
 Returns the sample standard deviation of the observations.
double getInterQuartileRange ()
 Returns the interquartile range of the observations, defined as the difference between the third and first quartiles.
double[] getParams ()
 Return a table containing parameters of the current distribution.
String toString ()
 Returns a String containing information about the current distribution.
Public Member Functions inherited from umontreal.ssj.probdist.DiscreteDistribution
 DiscreteDistribution (double[] values, double[] prob, int n)
 Constructs a discrete distribution over the \(n\) values contained in array values, with probabilities given in array prob.
 DiscreteDistribution (int[] values, double[] prob, int n)
 Similar to DiscreteDistribution(double[], double[], int).
double getValue (int i)
 Returns the \(i\)-th value \(x_i\), for \(0\le i<n\).
double getXinf ()
 Returns the lower limit \(x_0\) of the support of the distribution.
double getXsup ()
 Returns the upper limit \(x_{n-1}\) of the support of the distribution.

Static Public Member Functions

static double getMedian (double obs[], int n)
 Returns the median.

Detailed Description

Extends DiscreteDistribution to an empirical distribution function, based on the observations \(X_{(1)},…,X_{(n)}\) (sorted by increasing order).

The distribution is uniform over the \(n\) observations, so the distribution function has a jump of \(1/n\) at each of the \(n\) observations.

Definition at line 47 of file EmpiricalDist.java.

Constructor & Destructor Documentation

◆ EmpiricalDist() [1/2]

umontreal.ssj.probdist.EmpiricalDist.EmpiricalDist ( double[] obs)

Constructs a new empirical distribution using all the observations stored in obs, and which are assumed to have been sorted in increasing numerical order.

[1] These observations are copied into an internal array.

Definition at line 60 of file EmpiricalDist.java.

◆ EmpiricalDist() [2/2]

umontreal.ssj.probdist.EmpiricalDist.EmpiricalDist ( Reader in) throws IOException

Constructs a new empirical distribution using the observations read from the reader in.

This constructor will read the first double of each line in the stream. Any line that does not start with a +, -, or a decimal digit, is ignored. One must be careful about lines starting with a blank. This format is the same as in UNURAN. The observations read are assumed to have been sorted in increasing numerical order.

Definition at line 77 of file EmpiricalDist.java.

Member Function Documentation

◆ barF()

double umontreal.ssj.probdist.EmpiricalDist.barF ( double x)
Parameters
xvalue at which the complementary distribution function is evaluated
Returns
the complementary distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 129 of file EmpiricalDist.java.

◆ cdf()

double umontreal.ssj.probdist.EmpiricalDist.cdf ( double x)
Parameters
xvalue at which the cdf is evaluated
Returns
the cdf evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 117 of file EmpiricalDist.java.

◆ getInterQuartileRange()

double umontreal.ssj.probdist.EmpiricalDist.getInterQuartileRange ( )

Returns the interquartile range of the observations, defined as the difference between the third and first quartiles.

Definition at line 250 of file EmpiricalDist.java.

◆ getMean()

double umontreal.ssj.probdist.EmpiricalDist.getMean ( )

Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 170 of file EmpiricalDist.java.

◆ getMedian() [1/2]

double umontreal.ssj.probdist.EmpiricalDist.getMedian ( )

Returns the median.

Returns the \(n/2^{\mbox{th}}\) item of the sorted observations when the number of items is odd, and the mean of the

\(n/2^{\mbox{th}}\) and the \((n/2 + 1)^{\mbox{th}}\) items when the number of items is even.

Definition at line 189 of file EmpiricalDist.java.

◆ getMedian() [2/2]

double umontreal.ssj.probdist.EmpiricalDist.getMedian ( double obs[],
int n )
static

Returns the median.

Returns the \(n/2^{\mbox{th}}\) item of the array obs when the number of items is odd, and the mean of the

\(n/2^{\mbox{th}}\) and the \((n/2 + 1)^{\mbox{th}}\) items when the number of items is even. The array does not have to be sorted.

Parameters
obsthe array of observations
nthe number of observations
Returns
return the median of the observations

Definition at line 207 of file EmpiricalDist.java.

◆ getN()

int umontreal.ssj.probdist.EmpiricalDist.getN ( )

Returns \(n\), the number of observations.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 214 of file EmpiricalDist.java.

◆ getObs()

double umontreal.ssj.probdist.EmpiricalDist.getObs ( int i)

Returns the value of \(X_{(i)}\), for \(i=0, 1, …, n-1\).

Definition at line 221 of file EmpiricalDist.java.

◆ getParams()

double[] umontreal.ssj.probdist.EmpiricalDist.getParams ( )

Return a table containing parameters of the current distribution.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 269 of file EmpiricalDist.java.

◆ getSampleMean()

double umontreal.ssj.probdist.EmpiricalDist.getSampleMean ( )

Returns the sample mean of the observations.

Definition at line 228 of file EmpiricalDist.java.

◆ getSampleStandardDeviation()

double umontreal.ssj.probdist.EmpiricalDist.getSampleStandardDeviation ( )

Returns the sample standard deviation of the observations.

Definition at line 242 of file EmpiricalDist.java.

◆ getSampleVariance()

double umontreal.ssj.probdist.EmpiricalDist.getSampleVariance ( )

Returns the sample variance of the observations.

Definition at line 235 of file EmpiricalDist.java.

◆ getStandardDeviation()

double umontreal.ssj.probdist.EmpiricalDist.getStandardDeviation ( )

Computes the standard deviation of the distribution.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 174 of file EmpiricalDist.java.

◆ getVariance()

double umontreal.ssj.probdist.EmpiricalDist.getVariance ( )

Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 178 of file EmpiricalDist.java.

◆ inverseF()

double umontreal.ssj.probdist.EmpiricalDist.inverseF ( double u)
Parameters
uvalue in the interval \((0,1)\) for which the inverse distribution function is evaluated
Returns
the inverse distribution function evaluated at u
Exceptions
IllegalArgumentExceptionif \(u\) is not in the interval \((0,1)\)
ArithmeticExceptionif the inverse cannot be computed, for example if it would give infinity in a theoretical context

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 141 of file EmpiricalDist.java.

◆ prob()

double umontreal.ssj.probdist.EmpiricalDist.prob ( int i)

Returns \(p_i\), the probability of the \(i\)-th value, for.

\(0\le i<n\).

Parameters
ivalue number, \(0\le i < n\)
Returns
the probability of value i

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 111 of file EmpiricalDist.java.

◆ toString()

String umontreal.ssj.probdist.EmpiricalDist.toString ( )

Returns a String containing information about the current distribution.

Reimplemented from umontreal.ssj.probdist.DiscreteDistribution.

Definition at line 278 of file EmpiricalDist.java.


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