Bernoulli Distribution¶
Table of contents
Density Function¶
The density function of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dbern(x: int, prob: float, log: bool = False) float
Density function of the Bernoulli distribution.
Example
>>> pystats.dbern(1, 0.6) 0.6
- Parameters
x (int) – An integral-valued input, equal to 0 or 1.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dbern(x: List[int], prob: float, log: bool = False) float
Density function of the Bernoulli distribution.
Example
>>> pystats.dbern([0, 1], 0.6) [0.4, 0.6]
- Parameters
x (List[int]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pbern(p: int, prob: float, log: bool = False) float
Distribution function of the Bernoulli distribution.
Example
>>> pystats.pbern(1, 0.6) 1.0
- Parameters
p (int) – A value equal to 0 or 1.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pbern(p: List[int], prob: float, log: bool = False) float
Distribution function of the Bernoulli distribution.
Example
>>> pystats.pbern([0, 1], 0.6) [0.4, 1.0]
- Parameters
p (List[int]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the Bernoulli distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qbern(q: float, prob: float) float
Quantile function of the Bernoulli distribution.
Example
>>> pystats.qbern(0.5, 0.4) 0.0
- Parameters
q (float) – A real-valued input.
prob (float) – The probability parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qbern(q: List[float], prob: float) float
Quantile function of the Bernoulli distribution.
Example
>>> pystats.pbern([0.3, 0.7], 0.6) [0.0, 1.0]
- Parameters
q (List[float]) – A standard list input.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Bernoulli distribution is achieved via the inverse probability integral transform.
Scalar Output¶
- pystats.rbern(prob: float) float
Random sampling function for the Bernoulli distribution.
Example
>>> pystats.rbern(0.4) 0.0
- Parameters
prob (float) – The probability parameter, a real-valued input.
- Returns
A pseudo-random draw from the Bernoulli distribution.
List Output¶
- pystats.rbern(n: int, prob: float) float
Random sampling function for the Bernoulli distribution.
Example
>>> pystats.rbern(10, 0.4) [1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0]
- Parameters
n (int) – The number of output values.
prob (float) – The probability parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Bernoulli distribution.