Beta Distribution¶
Table of contents
Density Function¶
The density function of the Beta distribution:
where \(\mathcal{B}(a,b)\) denotes the Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dbeta(x: float, shape1: float, shape2: float, log: bool = False) float
Density function of the Beta distribution.
Example
>>> pystats.dbeta(0.5, 3.0, 2.0) 1.5
- Parameters
x (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dbeta(x: List[float], shape1: float, shape2: float, log: bool = False) List[float]
Density function of the Beta distribution.
Example
>>> pystats.dbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.756, 1.5, 0.972]
- Parameters
x (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
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 Beta distribution:
where \(I_x (a,b)\) denotes the regularized incomplete Beta function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pbeta(p: float, shape1: float, shape2: float, log: bool = False) float
Distribution function of the Beta distribution.
Example
>>> pystats.pbeta(0.5, 3.0, 2.0) 0.3125
- Parameters
p (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pbeta(p: List[float], shape1: float, shape2: float, log: bool = False) List[float]
Distribution function of the Beta distribution.
Example
>>> pystats.pbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.0837, 0.3125, 0.9477]
- Parameters
p (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
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 Beta distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qbeta(q: float, shape1: float, shape2: float) float
Quantile function of the Beta distribution.
Example
>>> pystats.qbeta(0.5, 3.0, 2.0) 0.61427243186
- Parameters
q (float) – A real-valued input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qbeta(q: List[float], shape1: float, shape2: float) List[float]
Quantile function of the Beta distribution.
Example
>>> pystats.qbeta([0.3, 0.5, 0.9], 3.0, 2.0) [0.4915952451274149, 0.6142724318676113, 0.8574406832899696]
- Parameters
q (List[float]) – A standard list input.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Beta distribution is achieved by simulating two independent gamma-distributed random variables, \(X \sim G(a,1), Y \sim G(a,1)\), then returning:
Scalar Output¶
- pystats.rbeta(shape1: float, shape2: float) float
Random sampling function for the Beta distribution.
Example
>>> pystats.rbeta(3.0, 2.0) 0.3102933967927699
- Parameters
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A pseudo-random draw from the Beta distribution.
List Output¶
- pystats.rbeta(n: int, shape1: float, shape2: float) List[float]
Random sampling function for the Beta distribution.
Example
>>> pystats.rbeta(5, 3.0, 2.0) [0.2098009340766354, 0.483502928842804, 0.5101449459492882, 0.46683636135288137, 0.791214142230094]
- Parameters
n (int) – The number of output values.
shape1 (float) – A real-valued shape parameter.
shape2 (float) – A real-valued shape parameter.
- Returns
A list of pseudo-random draws from the Beta distribution.