.. _examples-discrete: Discrete Distribution Examples ================================ Worked examples for common discrete distributions. For each example the range, PMF, and expected moment values are given. All results were verified against known analytical formulae. .. contents:: On this page :local: :depth: 2 ---- Bernoulli Distribution ----------------------- The Bernoulli distribution models a single binary trial with success probability :math:`p`. **Parameters:** :math:`p = 0.6` **Support:** 0, 1 .. code-block:: text Range: 0,1 PMF: 0.6 if x == 1 else 0.4 **Known moments about origin:** .. list-table:: :header-rows: 1 :widths: 15 85 * - Order - Value * - mu_1 - 0.6 (= p) * - mu_2 - 0.6 (= p, since X^2 = X for Bernoulli) * - mu_3 - 0.6 * - mu_4 - 0.6 **Known central moments:** .. list-table:: :header-rows: 1 :widths: 15 85 * - Order - Value * - mu_1 - 0 (always) * - mu_2 - 0.24 (= p*(1-p)) ---- Binomial Distribution ---------------------- The Binomial distribution models the number of successes in :math:`n` independent Bernoulli trials. **Parameters:** :math:`n = 10`, :math:`p = 0.4` **Support:** 0, 1, 2, …, 10 .. code-block:: text Range: 0,1,2,3,4,5,6,7,8,9,10 PMF: (factorial(10) / (factorial(x) * factorial(10-x))) * 0.4**x * 0.6**(10-x) **Known analytical values:** .. code-block:: text Mean = n*p = 4.0 Variance = n*p*(1-p) = 2.4 Std Dev = sqrt(2.4) ≈ 1.5492 Skewness = (1-2p)/sqrt(n*p*(1-p)) ≈ 0.1291 Kurtosis = 3 + (1-6p(1-p))/(n*p*(1-p)) ≈ 3.0583 ---- Geometric Distribution (failures before first success) ------------------------------------------------------- The Geometric distribution models the number of failures before the first success, with support starting at 0. **Parameters:** :math:`p = 0.3` **Support:** 0, 1, 2, 3, … .. code-block:: text Range: 0,1,2,3,... PMF: 0.3 * (0.7 ** x) if x >= 0 else 0 **Known analytical values:** .. code-block:: text Mean = (1-p)/p = 7/3 ≈ 2.3333 Variance = (1-p)/p² = 70/9 ≈ 7.7778 Skewness = (2-p)/sqrt(1-p) ≈ 2.031 Kurtosis = 9 + p²/(1-p) ≈ 9.129 ---- Geometric Distribution (trials until first success) ---------------------------------------------------- Alternative parameterisation: support starts at 1. **Parameters:** :math:`p = 0.3` .. code-block:: text Range: 1,2,3,4,... PMF: 0.3 * (0.7 ** (x-1)) if x >= 1 else 0 **Known analytical values:** .. code-block:: text Mean = 1/p = 10/3 ≈ 3.3333 Variance = (1-p)/p² ≈ 7.7778 (same as above) ---- Poisson Distribution --------------------- The Poisson distribution models the number of events in a fixed interval when events occur at constant rate :math:`\lambda`. **Parameters:** :math:`\lambda = 3` **Support:** 0, 1, 2, 3, … .. code-block:: text Range: 0,1,2,3,... PMF: (exp(-3) * 3**x) / factorial(x) if x >= 0 else 0 **Known analytical values:** .. code-block:: text Mean = λ = 3.0 Variance = λ = 3.0 Skewness = 1/sqrt(λ) ≈ 0.5774 Kurtosis = 3 + 1/λ = 3.3333 .. tip:: The Poisson distribution's PMF decays very quickly for large :math:`x` relative to :math:`\lambda`. With :math:`\lambda = 3`, 200 terms captures more than :math:`10^{-200}` of the total probability. ---- Negative Binomial Distribution -------------------------------- The Negative Binomial models the number of failures before the :math:`r`-th success. **Parameters:** :math:`r = 2`, :math:`p = 0.5` **Support:** 0, 1, 2, 3, … .. code-block:: text Range: 0,1,2,3,... PMF: (factorial(x+1) / (factorial(x) * factorial(1))) * 0.5**2 * 0.5**x if x >= 0 else 0 **Known analytical values:** .. code-block:: text Mean = r*(1-p)/p = 2 Variance = r*(1-p)/p² = 4 ---- Uniform Discrete Distribution ------------------------------ Equal probability over a finite set of values. **Parameters:** values 1 through 6 (fair die) .. code-block:: text Range: 1,2,3,4,5,6 PMF: 1/6 **Known analytical values:** .. code-block:: text Mean = (n+1)/2 = 3.5 Variance = (n²-1)/12 = 35/12 ≈ 2.9167 Skewness = 0 (symmetric) Kurtosis = 3 - (6(n²+1))/(5(n²-1)) ≈ 2.5143 ---- Tips for All Discrete Distributions ------------------------------------- * Set the moment reference to **Mean (a = μ)** and order ≥ 4 to see skewness and kurtosis in the Statistics tab. * Cross-check the first moment (μ₁) against the known analytical mean before trusting higher-order results. * For the Poisson distribution with small :math:`\lambda`, increasing **Calc precision** to 10 helps accuracy for the 4th moment and above. * If validation fails with sum ≠ 1, verify the PMF guard (``if x >= 0 else 0``) and check for typos in the exponent. See also -------- * :doc:`/user-guide/discrete-rv` — full DRV user guide * :doc:`/theory/convergence` — how infinite series are handled * :doc:`advanced-examples` — mixture distributions and custom PMFs