.. _examples-continuous: Continuous Distribution Examples ================================== Worked examples for standard continuous distributions. Expected values are the known analytical results; ToFUL results match to the displayed precision. .. contents:: On this page :local: :depth: 2 ---- Uniform Distribution --------------------- **Parameters:** :math:`a = 0`, :math:`b = 1` .. code-block:: text Lower: 0 Upper: 1 PDF: 1 if 0 <= x <= 1 else 0 **Known analytical values:** .. code-block:: text Mean = (a+b)/2 = 0.5 Variance = (b-a)²/12 = 1/12 ≈ 0.0833 Skewness = 0 (symmetric) Excess kurtosis = −6/5 = −1.2 (platykurtic) **Raw moments about origin:** .. math:: \mu'_r = \frac{1}{r+1} So :math:`\mu'_1 = 1/2`, :math:`\mu'_2 = 1/3`, :math:`\mu'_3 = 1/4`, :math:`\mu'_4 = 1/5`. ---- Exponential Distribution ------------------------- **Parameters:** :math:`\lambda = 2` .. code-block:: text Lower: 0 Upper: inf PDF: 2 * exp(-2*x) if x >= 0 else 0 **Known analytical values:** .. code-block:: text Mean = 1/λ = 0.5 Variance = 1/λ² = 0.25 Std Dev = 0.5 Skewness = 2 (strong right skew) Excess kurtosis = 6 (heavy tails) **Raw moments about origin:** .. math:: \mu'_r = \frac{r!}{\lambda^r} So :math:`\mu'_1 = 0.5`, :math:`\mu'_2 = 0.5`, :math:`\mu'_3 = 0.75`, :math:`\mu'_4 = 1.5`. .. note:: For this distribution, ToFUL uses Gauss-Laguerre quadrature (domain :math:`[0, \infty)`) and typically achieves near-exact results. The method shown will be ``gauss-laguerre+quad``. ---- Standard Normal Distribution ----------------------------- **Parameters:** :math:`\mu = 0`, :math:`\sigma = 1` .. code-block:: text Lower: -inf Upper: inf PDF: exp(-(x**2)/2) / sqrt(2*pi) **Known analytical values:** .. code-block:: text Mean = 0 Variance = 1 Skewness = 0 (symmetric) Kurtosis = 3 (excess = 0, mesokurtic) **Raw moments about origin:** All odd raw moments are 0. Even raw moments satisfy: .. math:: \mu'_{2k} = (2k-1)!! = 1 \cdot 3 \cdot 5 \cdots (2k-1) So :math:`\mu'_2 = 1`, :math:`\mu'_4 = 3`, :math:`\mu'_6 = 15`. .. tip:: The Normal PDF has no ``if/else`` guard, so ToFUL's SymPy path computes these moments exactly. The method shown will be ``sympy-exact`` and all values will be precise integers or exact fractions. ---- Normal Distribution (general) ------------------------------- **Parameters:** :math:`\mu = 3`, :math:`\sigma = 2` .. code-block:: text Lower: -inf Upper: inf PDF: exp(-((x-3)**2) / 8) / (2 * sqrt(2*pi)) **Known analytical values:** .. code-block:: text Mean = 3 Variance = 4 Std Dev = 2 Skewness = 0 Excess kurtosis = 0 ---- Gamma Distribution ------------------- **Parameters:** :math:`\alpha = 3` (shape), :math:`\beta = 1` (rate) .. code-block:: text Lower: 0 Upper: inf PDF: (x**2 * exp(-x)) / 2 if x >= 0 else 0 (This is the Gamma(3,1) PDF normalised by :math:`\Gamma(3) = 2! = 2`.) **Known analytical values:** .. code-block:: text Mean = α/β = 3 Variance = α/β² = 3 Skewness = 2/sqrt(α) ≈ 1.1547 Excess kurtosis = 6/α = 2 **Raw moments about origin:** .. math:: \mu'_r = \frac{\Gamma(\alpha + r)}{\beta^r\,\Gamma(\alpha)} = \frac{(\alpha+r-1)!}{(\alpha-1)!\,\beta^r} For :math:`\alpha = 3`, :math:`\beta = 1`: :math:`\mu'_1 = 3`, :math:`\mu'_2 = 12`, :math:`\mu'_3 = 60`, :math:`\mu'_4 = 360`. ---- Beta Distribution ------------------ **Parameters:** :math:`\alpha = 2`, :math:`\beta = 3` The normalising constant :math:`B(\alpha,\beta)^{-1} = \Gamma(\alpha+\beta)/(\Gamma(\alpha)\Gamma(\beta)) = 12`. .. code-block:: text Lower: 0 Upper: 1 PDF: 12 * x * (1-x)**2 if 0 <= x <= 1 else 0 **Known analytical values:** .. code-block:: text Mean = α/(α+β) = 0.4 Variance = αβ/((α+β)²(α+β+1)) = 0.04 Skewness ≈ 0.5963 Excess kurtosis ≈ −0.1429 ---- Triangular Distribution ------------------------ **Parameters:** lower = 0, upper = 2, mode = 1 .. code-block:: text Lower: 0 Upper: 2 PDF: x if 0<=x<=1 else (2-x) if 1