SSJ
V. 1.2.5.

umontreal.iro.lecuyer.probdist
Class GeometricDist

java.lang.Object
  extended by umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
      extended by umontreal.iro.lecuyer.probdist.GeometricDist
All Implemented Interfaces:
Distribution

public class GeometricDist
extends DiscreteDistributionInt

Extends the class DiscreteDistributionInt for the geometric distribution with parameter p, where 0 < p < 1. Its mass function is

p(x) = p (1 - p)x,        for x = 0, 1, 2,…

The distribution function is given by

F(x) = 1 - (1 - p)x+1,        for x = 0, 1, 2,…

and its inverse is

F-1(u) = floor(ln(1 - u)/ln(1 - p)),        for 0 <= u < 1.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
 
Constructor Summary
GeometricDist(double p)
          Constructs a geometric distribution with parameter p.
 
Method Summary
static double barF(double p, int x)
          Computes the complementary distribution function bar(F)(x).
 double barF(int x)
          Returns bar(F)(x), the complementary distribution function.
static double cdf(double p, int x)
          Computes the distribution function F(x).
 double cdf(int x)
          Returns the distribution function F evaluated at x (see).
static GeometricDist getInstanceFromMLE(int[] x, int n)
          Creates a new instance of a geometric distribution with parameter p estimated using the maximum likelihood method based on the n observations in table x[i], i = 0, 1,…, n - 1.
static double[] getMaximumLikelihoodEstimate(int[] x, int n)
          Estimates and returns the parameter [hat(p)] of the geometric distribution using the maximum likelihood method based on the n observations in table x[i], i = 0, 1,…, n - 1.
 double getMean()
          Returns the mean of the distribution function.
static double getMean(double p)
          Computes and returns the mean E[X] = (1 - p)/p of the geometric distribution with parameter p.
 double getP()
          Returns the p associated with this object.
 double getStandardDeviation()
          Returns the standard deviation of the distribution function.
static double getStandardDeviation(double p)
          Computes and returns the standard deviation of the geometric distribution with parameter p.
 double getVariance()
          Returns the variance of the distribution function.
static double getVariance(double p)
          Computes and returns the variance Var[X] = (1 - p)/p2 of the geometric distribution with parameter p.
static int inverseF(double p, double u)
          Computes the inverse of the geometric distribution.
 int inverseFInt(double u)
          Returns the inverse distribution function F-1(u), where 0 <= u <= 1.
static double prob(double p, int x)
          Computes the probability mass function p(x).
 double prob(int x)
          Returns p(x), the probability of x, which should be a real number in the interval [0, 1].
 void setP(double p)
          Resets the value of p associated with this object.
 
Methods inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
barF, cdf, inverseF
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometricDist

public GeometricDist(double p)
Constructs a geometric distribution with parameter p.

Method Detail

prob

public double prob(int x)
Description copied from class: DiscreteDistributionInt
Returns p(x), the probability of x, which should be a real number in the interval [0, 1].

Specified by:
prob in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns the distribution function F evaluated at x (see).

Specified by:
cdf in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns bar(F)(x), the complementary distribution function.

Overrides:
barF in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.

Overrides:
inverseFInt in class DiscreteDistributionInt
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: Distribution
Returns the mean of the distribution function.


getVariance

public double getVariance()
Description copied from interface: Distribution
Returns the variance of the distribution function.


getStandardDeviation

public double getStandardDeviation()
Description copied from interface: Distribution
Returns the standard deviation of the distribution function.


prob

public static double prob(double p,
                          int x)
Computes the probability mass function p(x).


cdf

public static double cdf(double p,
                         int x)
Computes the distribution function F(x).


barF

public static double barF(double p,
                          int x)
Computes the complementary distribution function bar(F)(x).


inverseF

public static int inverseF(double p,
                           double u)
Computes the inverse of the geometric distribution.


getInstanceFromMLE

public static GeometricDist getInstanceFromMLE(int[] x,
                                               int n)
Creates a new instance of a geometric distribution with parameter p estimated using the maximum likelihood method based on the n observations in table x[i], i = 0, 1,…, n - 1.

Parameters:
x - the list of observations to use to evaluate parameters
n - the number of observations to use to evaluate parameters

getMaximumLikelihoodEstimate

public static double[] getMaximumLikelihoodEstimate(int[] x,
                                                    int n)
Estimates and returns the parameter [hat(p)] of the geometric distribution using the maximum likelihood method based on the n observations in table x[i], i = 0, 1,…, n - 1.

Parameters:
x - the list of observations used to evaluate parameters
n - the number of observations used to evaluate parameters
Returns:
returns the parameter [hat(p)]

getMean

public static double getMean(double p)
Computes and returns the mean E[X] = (1 - p)/p of the geometric distribution with parameter p.

Returns:
the mean of the geometric distribution E[X] = (1 - p)/p

getVariance

public static double getVariance(double p)
Computes and returns the variance Var[X] = (1 - p)/p2 of the geometric distribution with parameter p.

Returns:
the variance of the Geometric distribution Var[X] = (1 - p)/p2

getStandardDeviation

public static double getStandardDeviation(double p)
Computes and returns the standard deviation of the geometric distribution with parameter p.

Returns:
the standard deviation of the geometric distribution

getP

public double getP()
Returns the p associated with this object.


setP

public void setP(double p)
Resets the value of p associated with this object.


SSJ
V. 1.2.5.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.