umontreal.iro.lecuyer.probdist
Class UniformIntDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
-
- umontreal.iro.lecuyer.probdist.UniformIntDist
-
- All Implemented Interfaces:
- Distribution
public class UniformIntDist extends DiscreteDistributionInt
Extends the classDiscreteDistributionIntfor the discrete uniform distribution over the range [i, j]. Its mass function is given byp(x) = 1/(j - i + 1) for x = i, i + 1,…, jand 0 elsewhere. The distribution function isF(x) = (floor(x) - i + 1)/(j - i + 1) for i <= x <= jand its inverse isF-1(u) = i + (j - i + 1)u for 0 <= u <= 1.
-
-
Field Summary
-
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
-
-
Constructor Summary
Constructors Constructor and Description UniformIntDist(int i, int j)Constructs a discrete uniform distribution over the interval [i, j].
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublebarF(int x)Returns bar(F)(x), the complementary distribution function.static doublebarF(int i, int j, int x)Computes the discrete uniform complementary distribution function bar(F)(x).doublecdf(int x)Returns the distribution function F evaluated at x (see).static doublecdf(int i, int j, int x)Computes the discrete uniform distribution function defined in.intgetI()Returns the parameter i.static UniformIntDistgetInstanceFromMLE(int[] x, int n)Creates a new instance of a discrete uniform distribution over integers with parameters i and j estimated using the maximum likelihood method based on the n observations x[k], k = 0, 1,…, n - 1.intgetJ()Returns the parameter j.doublegetMean()Returns the mean of the distribution function.static doublegetMean(int i, int j)Computes and returns the mean E[X] = (i + j)/2 of the discrete uniform distribution.static double[]getMLE(int[] x, int n)Estimates the parameters (i, j) of the uniform distribution over integers using the maximum likelihood method, from the n observations x[k], k = 0, 1,…, n - 1.double[]getParams()Return a table containing the parameters of the current distribution.doublegetStandardDeviation()Returns the standard deviation of the distribution function.static doublegetStandardDeviation(int i, int j)Computes and returns the standard deviation of the discrete uniform distribution.doublegetVariance()Returns the variance of the distribution function.static doublegetVariance(int i, int j)Computes and returns the variance Var[X] = [(j - i + 1)2 -1]/12 of the discrete uniform distribution.static intinverseF(int i, int j, double u)Computes the inverse of the discrete uniform distribution function.intinverseFInt(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.doubleprob(int x)Returns p(x), the probability of x, which should be a real number in the interval [0, 1].static doubleprob(int i, int j, int x)Computes the discrete uniform probability p(x).voidsetParams(int i, int j)Sets the parameters i and j for this object.java.lang.StringtoString()
-
-
-
Constructor Detail
-
UniformIntDist
public UniformIntDist(int i, int j)Constructs a discrete uniform distribution over the interval [i, j].
-
-
Method Detail
-
prob
public double prob(int x)
Description copied from class:DiscreteDistributionIntReturns p(x), the probability of x, which should be a real number in the interval [0, 1].- Specified by:
probin classDiscreteDistributionInt- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(int x)
Description copied from class:DiscreteDistributionIntReturns the distribution function F evaluated at x (see).- Specified by:
cdfin classDiscreteDistributionInt- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
barF
public double barF(int x)
Description copied from class:DiscreteDistributionIntReturns bar(F)(x), the complementary distribution function. See the WARNING above.- Overrides:
barFin classDiscreteDistributionInt- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
inverseFInt
public int inverseFInt(double u)
Description copied from class:DiscreteDistributionIntReturns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.- Overrides:
inverseFIntin classDiscreteDistributionInt- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Description copied from interface:DistributionReturns the mean of the distribution function.
-
getVariance
public double getVariance()
Description copied from interface:DistributionReturns the variance of the distribution function.
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:DistributionReturns the standard deviation of the distribution function.
-
prob
public static double prob(int i, int j, int x)Computes the discrete uniform probability p(x).
-
cdf
public static double cdf(int i, int j, int x)Computes the discrete uniform distribution function defined in.
-
barF
public static double barF(int i, int j, int x)Computes the discrete uniform complementary distribution function bar(F)(x). WARNING: The complementary distribution function is defined as bar(F)(x) = P[X >= x].
-
inverseF
public static int inverseF(int i, int j, double u)Computes the inverse of the discrete uniform distribution function.
-
getMLE
public static double[] getMLE(int[] x, int n)Estimates the parameters (i, j) of the uniform distribution over integers using the maximum likelihood method, from the n observations x[k], k = 0, 1,…, n - 1. The estimates are returned in a two-element array, in regular order: [i, j].- Parameters:
x- the list of observations used to evaluate parametersn- the number of observations used to evaluate parameters- Returns:
- returns the parameters [ hat(ı), hat(&jnodot;)]
-
getInstanceFromMLE
public static UniformIntDist getInstanceFromMLE(int[] x, int n)
Creates a new instance of a discrete uniform distribution over integers with parameters i and j estimated using the maximum likelihood method based on the n observations x[k], k = 0, 1,…, n - 1.- Parameters:
x- the list of observations to use to evaluate parametersn- the number of observations to use to evaluate parameters
-
getMean
public static double getMean(int i, int j)Computes and returns the mean E[X] = (i + j)/2 of the discrete uniform distribution.- Returns:
- the mean of the discrete uniform distribution
-
getVariance
public static double getVariance(int i, int j)Computes and returns the variance Var[X] = [(j - i + 1)2 -1]/12 of the discrete uniform distribution.- Returns:
- the variance of the discrete uniform distribution
-
getStandardDeviation
public static double getStandardDeviation(int i, int j)Computes and returns the standard deviation of the discrete uniform distribution.- Returns:
- the standard deviation of the discrete uniform distribution
-
getI
public int getI()
Returns the parameter i.
-
getJ
public int getJ()
Returns the parameter j.
-
setParams
public void setParams(int i, int j)Sets the parameters i and j for this object.
-
getParams
public double[] getParams()
Return a table containing the parameters of the current distribution. This table is put in regular order: [i, j].
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG