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

Extends the class DiscreteDistributionInt for the Bernoulli distribution [114]  with parameter \(p\), where. More...

Inheritance diagram for umontreal.ssj.probdist.BernoulliDist:
umontreal.ssj.probdist.DiscreteDistributionInt umontreal.ssj.probdist.Distribution

Public Member Functions

 BernoulliDist (double p)
 Creates a Bernoulli distribution object.
double prob (int x)
 Returns \(p(x)\), the probability of \(x\).
double cdf (int x)
 Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).
double barF (int x)
 Returns \(\bar{F}(x)\), the complementary distribution function.
int inverseFInt (double u)
 Returns the inverse distribution function \(F^{-1}(u)\), where.
double getMean ()
 Returns the mean of the distribution function.
double getVariance ()
 Returns the variance of the distribution function.
double getStandardDeviation ()
 Returns the standard deviation of the distribution function.
double getP ()
 Returns the parameter \(p\) of this object.
double[] getParams ()
 Returns an array that contains the parameter \(p\) of the current distribution: [ \(p\)].
void setParams (double p)
 Resets the parameter to this new value.
String toString ()
 Returns a String containing information about the current distribution.
Public Member Functions inherited from umontreal.ssj.probdist.DiscreteDistributionInt
double cdf (double x)
 Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).
double barF (double x)
 Returns \(\bar{F}(x)\), the complementary distribution function.
int getXinf ()
 Returns the lower limit \(x_a\) of the support of the probability mass function.
int getXsup ()
 Returns the upper limit \(x_b\) of the support of the probability mass function.
double inverseF (double u)
 Returns the inverse distribution function \(F^{-1}(u)\), where.

Static Public Member Functions

static double prob (double p, int x)
 Returns the Bernoulli probability \(f(x)\) with parameter \(p\) (see eq.
static double cdf (double p, int x)
 Returns the Bernoulli distribution function \(F(x)\) with parameter \(p\) (see eq.
static double barF (double p, int x)
 Returns the complementary Bernoulli distribution function.
static int inverseF (double p, double u)
 Returns the inverse of the Bernoulli distribution function with parameter \(p\) at \(u\).
static double[] getMLE (int[] x, int m)
 Estimates the parameters \(p\) of the Bernoulli distribution using the maximum likelihood method, from the \(m\) observations.
static BernoulliDist getInstanceFromMLE (int[] x, int m)
 Creates a new instance of a Bernoulli distribution with parameter.
static double getMean (double p)
 Returns the mean \(E[X] = p\) of the Bernoulli distribution with parameter \(p\).
static double getVariance (double p)
 Computes the variance \(\mbox{Var}[X] = p(1 - p)\) of the Bernoulli distribution with parameter \(p\).
static double getStandardDeviation (double p)
 Computes the standard deviation of the Bernoulli distribution with parameter \(p\).

Additional Inherited Members

Static Public Attributes inherited from umontreal.ssj.probdist.DiscreteDistributionInt
static double EPSILON = 1.0e-16
 Environment variable that determines what probability terms can be considered as negligible when building precomputed tables for distribution and mass functions.

Detailed Description

Extends the class DiscreteDistributionInt for the Bernoulli distribution [114]  with parameter \(p\), where.

\(0\le p\le1\). Its mass function is given by

\[ f(x) = \begin{cases} 1 - p, \qquad & \text{if $x = 0$;} \\ p, & \text{if $x = 1$;} \tag{fmass-bernoulli} \\ 0, & \text{otherwise.} \end{cases} \]

Its distribution function is

\[ F(x) = \begin{cases} 0, & \text{if $x < 0$;} \\ 1 - p, \qquad & \text{if $0 \le x < 1$;} \tag{cdf-bernoulli} \\ 1, & \text{if $x \ge1$.} \end{cases} \]

Definition at line 43 of file BernoulliDist.java.

Constructor & Destructor Documentation

◆ BernoulliDist()

umontreal.ssj.probdist.BernoulliDist.BernoulliDist ( double p)

Creates a Bernoulli distribution object.

Definition at line 50 of file BernoulliDist.java.

Member Function Documentation

◆ barF() [1/2]

double umontreal.ssj.probdist.BernoulliDist.barF ( double p,
int x )
static

Returns the complementary Bernoulli distribution function.

\(\bar{F}(x) = P[X \ge x]\) with parameter \(p\).

Definition at line 137 of file BernoulliDist.java.

◆ barF() [2/2]

double umontreal.ssj.probdist.BernoulliDist.barF ( int x)

Returns \(\bar{F}(x)\), the complementary distribution function.

See the WARNING above. The default implementation returns 1.0 - cdf(x - 1), which is not accurate when \(F(x)\) is near 1.

Parameters
xvalue at which the complementary distribution function must be evaluated
Returns
the complementary distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 75 of file BernoulliDist.java.

◆ cdf() [1/2]

double umontreal.ssj.probdist.BernoulliDist.cdf ( double p,
int x )
static

Returns the Bernoulli distribution function \(F(x)\) with parameter \(p\) (see eq.

( cdf-bernoulli )).

Definition at line 122 of file BernoulliDist.java.

◆ cdf() [2/2]

double umontreal.ssj.probdist.BernoulliDist.cdf ( int x)

Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).

Parameters
xvalue at which the distribution function must be evaluated
Returns
the distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 67 of file BernoulliDist.java.

◆ getInstanceFromMLE()

BernoulliDist umontreal.ssj.probdist.BernoulliDist.getInstanceFromMLE ( int[] x,
int m )
static

Creates a new instance of a Bernoulli distribution with parameter.

\(p\) estimated using the maximum likelihood method, from the \(m\) observations \(x[i]\), \(i = 0, 1, …, m-1\).

Parameters
xthe list of observations to use to estimate the parameters
mthe number of observations to use to estimate the parameters

Definition at line 194 of file BernoulliDist.java.

◆ getMean() [1/2]

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

Returns the mean of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 91 of file BernoulliDist.java.

◆ getMean() [2/2]

double umontreal.ssj.probdist.BernoulliDist.getMean ( double p)
static

Returns the mean \(E[X] = p\) of the Bernoulli distribution with parameter \(p\).

Returns
the mean of the Bernoulli distribution \(E[X] = np\)

Definition at line 206 of file BernoulliDist.java.

◆ getMLE()

double[] umontreal.ssj.probdist.BernoulliDist.getMLE ( int[] x,
int m )
static

Estimates the parameters \(p\) of the Bernoulli distribution using the maximum likelihood method, from the \(m\) observations.

\(x[i]\), \(i = 0, 1,…, m-1\). The estimate is returned in a one-element array: [ \(p\)].

Parameters
xthe list of observations used to evaluate parameters
mthe number of observations used to evaluate parameters
Returns
returns the parameter [ \(\hat{p}\)]

Definition at line 171 of file BernoulliDist.java.

◆ getP()

double umontreal.ssj.probdist.BernoulliDist.getP ( )

Returns the parameter \(p\) of this object.

Definition at line 238 of file BernoulliDist.java.

◆ getParams()

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

Returns an array that contains the parameter \(p\) of the current distribution: [ \(p\)].

Implements umontreal.ssj.probdist.Distribution.

Definition at line 246 of file BernoulliDist.java.

◆ getStandardDeviation() [1/2]

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

Returns the standard deviation of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 99 of file BernoulliDist.java.

◆ getStandardDeviation() [2/2]

double umontreal.ssj.probdist.BernoulliDist.getStandardDeviation ( double p)
static

Computes the standard deviation of the Bernoulli distribution with parameter \(p\).

Returns
the standard deviation of the Bernoulli distribution

Definition at line 231 of file BernoulliDist.java.

◆ getVariance() [1/2]

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

Returns the variance of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 95 of file BernoulliDist.java.

◆ getVariance() [2/2]

double umontreal.ssj.probdist.BernoulliDist.getVariance ( double p)
static

Computes the variance \(\mbox{Var}[X] = p(1 - p)\) of the Bernoulli distribution with parameter \(p\).

Returns
the variance of the Bernoulli distribution

Definition at line 219 of file BernoulliDist.java.

◆ inverseF()

int umontreal.ssj.probdist.BernoulliDist.inverseF ( double p,
double u )
static

Returns the inverse of the Bernoulli distribution function with parameter \(p\) at \(u\).

Definition at line 151 of file BernoulliDist.java.

◆ inverseFInt()

int umontreal.ssj.probdist.BernoulliDist.inverseFInt ( double u)

Returns the inverse distribution function \(F^{-1}(u)\), where.

\(0\le u\le1\). The default implementation uses binary search.

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 theoritical context

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 83 of file BernoulliDist.java.

◆ prob() [1/2]

double umontreal.ssj.probdist.BernoulliDist.prob ( double p,
int x )
static

Returns the Bernoulli probability \(f(x)\) with parameter \(p\) (see eq.

( fmass-bernoulli )).

Definition at line 107 of file BernoulliDist.java.

◆ prob() [2/2]

double umontreal.ssj.probdist.BernoulliDist.prob ( int x)

Returns \(p(x)\), the probability of \(x\).

Parameters
xvalue at which the mass function must be evaluated
Returns
the mass function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 59 of file BernoulliDist.java.

◆ setParams()

void umontreal.ssj.probdist.BernoulliDist.setParams ( double p)

Resets the parameter to this new value.

Definition at line 254 of file BernoulliDist.java.

◆ toString()

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

Returns a String containing information about the current distribution.

Definition at line 262 of file BernoulliDist.java.


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