umontreal.iro.lecuyer.probdist
Class PiecewiseLinearEmpiricalDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.ContinuousDistribution
-
- umontreal.iro.lecuyer.probdist.PiecewiseLinearEmpiricalDist
-
- All Implemented Interfaces:
- Distribution
public class PiecewiseLinearEmpiricalDist extends ContinuousDistribution
Extends the classContinuousDistributionfor a piecewise-linear approximation of the empirical distribution function, based on the observations X(1),..., X(n) (sorted by increasing order), and defined as follows (e.g.,). The distribution function starts at X(1) and climbs linearly by 1/(n - 1) between any two successive observations. The density isf (x) = 1/[(n - 1)(X(i+1) - X(i))] for X(i) <= x < X(i+1) and i = 1, 2,..., n - 1.The distribution function iswhose inverse isF(x) = 0 for x < X(1), F(x) = (i - 1)/(n - 1) + (x - X(i))/[(n - 1)(X(i+1) - X(i))] for X(i) <= x < X(i+1), F(x) = 1 elsewhere, F-1(u) = X(i) + ((n - 1)u - i + 1)(X(i+1) - X(i))for (i - 1)/(n - 1) <= u <= i/(n - 1) and i = 1,..., n - 1.
-
-
Field Summary
-
Fields inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
decPrec
-
-
Constructor Summary
Constructors Constructor and Description PiecewiseLinearEmpiricalDist(double[] obs)Constructs a new piecewise-linear distribution using all the observations stored in obs.PiecewiseLinearEmpiricalDist(java.io.Reader in)Constructs a new empirical distribution using the observations read from the reader in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublebarF(double x)Returns the complementary distribution function.doublecdf(double x)Returns the distribution function F(x).doubledensity(double x)Returns f (x), the density evaluated at x.doublegetMean()Returns the mean.intgetN()Returns n, the number of observations.doublegetObs(int i)Returns the value of X(i).double[]getParams()Return a table containing parameters of the current distribution.doublegetSampleMean()Returns the sample mean of the observations.doublegetSampleStandardDeviation()Returns the sample standard deviation of the observations.doublegetSampleVariance()Returns the sample variance of the observations.doublegetStandardDeviation()Returns the standard deviation.doublegetVariance()Returns the variance.doubleinverseF(double u)Returns the inverse distribution function x = F-1(u).java.lang.StringtoString()Returns a String containing information about the current distribution.-
Methods inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
getXinf, getXsup, inverseBisection, inverseBrent, setXinf, setXsup
-
-
-
-
Constructor Detail
-
PiecewiseLinearEmpiricalDist
public PiecewiseLinearEmpiricalDist(double[] obs)
Constructs a new piecewise-linear distribution using all the observations stored in obs. These observations are copied into an internal array and then sorted.
-
PiecewiseLinearEmpiricalDist
public PiecewiseLinearEmpiricalDist(java.io.Reader in) throws java.io.IOExceptionConstructs 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. The file is read until its end. One must be careful about lines starting with a blank. This format is the same as in UNURAN.- Throws:
java.io.IOException
-
-
Method Detail
-
density
public double density(double x)
Description copied from class:ContinuousDistributionReturns f (x), the density evaluated at x.- Specified by:
densityin classContinuousDistribution- Parameters:
x- value at which the density is evaluated- Returns:
- density function evaluated at x
-
cdf
public double cdf(double x)
Description copied from interface:DistributionReturns the distribution function F(x).- Parameters:
x- value at which the distribution function is evaluated- Returns:
- distribution function evaluated at x
-
barF
public double barF(double x)
Description copied from class:ContinuousDistributionReturns the complementary distribution function. The default implementation computes bar(F)(x) = 1 - F(x).- Specified by:
barFin interfaceDistribution- Overrides:
barFin classContinuousDistribution- Parameters:
x- value at which the complementary distribution function is evaluated- Returns:
- complementary distribution function evaluated at x
-
inverseF
public double inverseF(double u)
Description copied from class:ContinuousDistributionReturns the inverse distribution function x = F-1(u). Restrictions: u∈[0, 1].- Specified by:
inverseFin interfaceDistribution- Overrides:
inverseFin classContinuousDistribution- Parameters:
u- value at which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Description copied from class:ContinuousDistributionReturns the mean.- Specified by:
getMeanin interfaceDistribution- Overrides:
getMeanin classContinuousDistribution- Returns:
- the mean
-
getVariance
public double getVariance()
Description copied from class:ContinuousDistributionReturns the variance.- Specified by:
getVariancein interfaceDistribution- Overrides:
getVariancein classContinuousDistribution- Returns:
- the variance
-
getStandardDeviation
public double getStandardDeviation()
Description copied from class:ContinuousDistributionReturns the standard deviation.- Specified by:
getStandardDeviationin interfaceDistribution- Overrides:
getStandardDeviationin classContinuousDistribution- Returns:
- the standard deviation
-
getN
public int getN()
Returns n, the number of observations.
-
getObs
public double getObs(int i)
Returns the value of X(i).
-
getSampleMean
public double getSampleMean()
Returns the sample mean of the observations.
-
getSampleVariance
public double getSampleVariance()
Returns the sample variance of the observations.
-
getSampleStandardDeviation
public double getSampleStandardDeviation()
Returns the sample standard deviation of the observations.
-
getParams
public double[] getParams()
Return a table containing parameters of the current distribution.
-
toString
public java.lang.String toString()
Returns a String containing information about the current distribution.- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG