SSJ
V. labo.

umontreal.iro.lecuyer.probdist
Class BernoulliDist

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

public class BernoulliDist
extends DiscreteDistributionInt

BernoulliDist

Extends the class DiscreteDistributionInt for the Bernoulli distribution[#!sLAW00a!#] with parameter p, where 0≤p≤1. Its mass function is given by

f (x) = 1 - p,          if x = 0;
f (x) = p,          if x = 1;
f (x) = 0,          otherwise.

Its distribution function is

F(x) = 0,          if x < 0;
F(x) = 1 - p,          if 0≤x < 1;
F(x) = 1,          if x≥1.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
 
Constructor Summary
BernoulliDist(double p)
          .
 
Method Summary
static double barF(double p, int x)
          .
 double barF(int x)
          Returns bar(F)(x), the complementary distribution function.
static double cdf(double p, int x)
          .
 double cdf(int x)
          Returns the distribution function F evaluated at x (see).
static BernoulliDist getInstanceFromMLE(int[] x, int m)
          .
 double getMean()
          .
static double getMean(double p)
          .
static double[] getMLE(int[] x, int m)
          .
 double getP()
          .
 double[] getParams()
          .
 double getStandardDeviation()
          .
static double getStandardDeviation(double p)
          .
 double getVariance()
          .
static double getVariance(double p)
          .
static int inverseF(double p, double u)
          .
 int inverseFInt(double u)
          Returns the inverse distribution function F-1(u), where 0 <= u <= 1.
static double prob(double p, int x)
          .
 double prob(int x)
          Returns p(x), the probability of x.
 void setParams(double p)
          .
 String toString()
          .
 
Methods inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
barF, cdf, getXinf, getXsup, inverseF
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BernoulliDist

public BernoulliDist(double p)
. \begin{tabb}Creates a Bernoulli distribution object.
 \end{tabb}

Method Detail

prob

public double prob(int x)
Description copied from class: DiscreteDistributionInt
Returns p(x), the probability of x.

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. See the WARNING above.

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
. \begin{tabb}Returns the mean of the distribution function.
 \end{tabb}


getVariance

public double getVariance()
Description copied from interface: Distribution
. \begin{tabb}Returns the variance of the distribution function.
 \end{tabb}


getStandardDeviation

public double getStandardDeviation()
Description copied from interface: Distribution
. \begin{tabb}Returns the standard deviation of the distribution function.
 \end{tabb}


prob

public static double prob(double p,
                          int x)
. \begin{tabb}Returns the Bernoulli probability $f(x)$\ with parameter $p$
 (see eq.).
 \end{tabb}


cdf

public static double cdf(double p,
                         int x)
. \begin{tabb}Returns the Bernoulli distribution function $F(x)$
 with parameter $p$\ (see eq.).
 \end{tabb}


barF

public static double barF(double p,
                          int x)
. \begin{tabb}Returns the complementary Bernoulli distribution
 function $\bar F(x) = P[X \ge x]$\ with parameter $p$.
 \end{tabb}


inverseF

public static int inverseF(double p,
                           double u)
. \begin{tabb}Returns the inverse of the Bernoulli distribution function
 with parameter $p$\ at $u$.
 \end{tabb}


getMLE

public static double[] getMLE(int[] x,
                              int m)
. \begin{tabb}
 Estimates the parameters $p$\ of the Bernoulli distribution
 using...
 ...ldots, m-1$. The estimate is returned in a one-element
 array: [$p$].
 \end{tabb}
xthe list of observations used to evaluate parameters mthe number of observations used to evaluate parameters returns the parameter [$ \hat{{p}}$]


getInstanceFromMLE

public static BernoulliDist getInstanceFromMLE(int[] x,
                                               int m)
. \begin{tabb}
 Creates a new instance of a Bernoulli distribution with parameter
 ...
 ... method, from
 the $m$\ observations $x[i]$, $i = 0, 1, \ldots, m-1$.
 \end{tabb}
xthe list of observations to use to estimate the parameters mthe number of observations to use to estimate the parameters


getMean

public static double getMean(double p)
. \begin{tabb}Returns the mean $E[X] = p$\ of the Bernoulli distribution with
 parameter $p$.
 \end{tabb}
the mean of the Bernoulli distribution E[X] = np


getVariance

public static double getVariance(double p)
. \begin{tabb}Computes the variance $\mbox{Var}[X] = p(1 - p)$\ of the Bernoulli
 distribution with parameter $p$.
 \end{tabb}
the variance of the Bernoulli distribution


getStandardDeviation

public static double getStandardDeviation(double p)
. \begin{tabb}Computes the standard deviation of the Bernoulli distribution
 with parameter $p$.
 \end{tabb}
the standard deviation of the Bernoulli distribution


getP

public double getP()
. \begin{tabb}
 Returns the parameter $p$\ of this object.
 \end{tabb}


getParams

public double[] getParams()
. \begin{tabb}
 Returns an array that contains the parameter $p$\ of the current
 distribution: [$p$].
 \end{tabb}


setParams

public void setParams(double p)
. \begin{tabb}
 Resets the parameter to this new value.
 \end{tabb}

 


toString

public String toString()
. \begin{hide}
 \par
 \begin{tabb}
 Returns a \texttt{String} containing information about the current distribution.
 \end{tabb}\end{hide}

Overrides:
toString in class Object

SSJ
V. labo.

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