beta

final class boring_math.probability_distributions.distributions.beta.Beta

Bases: ContDist

Class for visualizing Beta distributions.

The Beta distribution is a continuous probability distribution defined on the sample space [0, 1] with probability density function

f(x) = xᵅ⁻¹(1-x)ᵝ⁻¹/B(α,β) for α,β > 0

where

  • μ = α/(α+β)

  • σ² =  αβ/((α+β)²(α+β+1))

  • mode = (α-1)/(α+β-2) for α, β > 1

  • B(α,β) = Γ(α)Γ(β)/Γ(α+β) is the normalization factor.

Note

There is no simple closed form formula the CDF valid for all α, β > 0. To provide a CDF the PDF is numerically integrated by the parent class.

TODO

Implement a CDF using using the Incomplete Beta Function once one is implemented in boring-math-special-functions.

__init__(α: float, β: float)
pdf(x: float) float

Beta PDF

Beta probability distribution function.

Parameters:

xx [0, 1]

Returns:

Value of the PDF at x, 0,0 if outside domain.

cdf(x: float) float

Beta CDF

Beta cumulative probability distribution function defined on the probability sample space [0, 1].

Note

For all α, β > 0 there is no single closed form for a beta distribution’s CDF. To provide a CDf, the PDF is numerically integrated.

Parameters:

x – Where x is an element of the sample space.

Returns:

CDF at x obtained by numerically integrated the PDF.

__add__(other: Self) Self

Fail if two Beta distributions are added.

Beta distributions are not stable, thus the sum of two random beta distributed variables is not Beta distributed.

Parameters:

other – Another Beta distribution class instance.

Returns:

Never returns, Beta distributions are not stable.

Raises:
  • ValueError – If Beta distributions are added.

  • TypeError – If a Beta distributions is added to another type of probability distribution class.

__repr__() str
Returns:

The string Beta(α, β) where α, β > 0.

__str__() str
Returns:

The string Beta(a=α, b=β) where α, β > 0.