.. _theory-moments: Statistical Moments ==================== Statistical moments are a family of summary statistics that describe the shape of a probability distribution. ToFUL computes the *r*-th moment of a random variable X about a reference point *a*, defined as: .. math:: \mu_r(a) = E\left[(X - a)^r\right] .. contents:: On this page :local: :depth: 2 ---- Definition ---------- For a **discrete random variable** with PMF :math:`P(X = x)`: .. math:: \mu_r(a) = \sum_{x} (x - a)^r \cdot P(X = x) For a **continuous random variable** with PDF :math:`f(x)`: .. math:: \mu_r(a) = \int_{-\infty}^{\infty} (x - a)^r \cdot f(x)\, dx The choice of reference point *a* determines the *type* of moment. ---- Types of Moments ----------------- Raw Moments (a = 0) ~~~~~~~~~~~~~~~~~~~~ Setting :math:`a = 0` gives the *raw moments* (also called moments about the origin): .. math:: \mu'_r = E[X^r] The first few raw moments have direct interpretations: +-------+--------------------+-------------------------------------------+ | Order | Raw moment | Interpretation | +=======+====================+===========================================+ | r = 1 | :math:`\mu'_1` | **Mean** mu = E[X] | +-------+--------------------+-------------------------------------------+ | r = 2 | :math:`\mu'_2` | E[X^2] -- used to compute variance | +-------+--------------------+-------------------------------------------+ | r = 3 | :math:`\mu'_3` | E[X^3] | +-------+--------------------+-------------------------------------------+ | r = 4 | :math:`\mu'_4` | E[X^4] | +-------+--------------------+-------------------------------------------+ Central Moments (a = μ) ~~~~~~~~~~~~~~~~~~~~~~~~ Setting :math:`a = \mu` gives the *central moments*: .. math:: \mu_r = E\left[(X - \mu)^r\right] Central moments measure deviations from the mean and are therefore invariant to shifts in the distribution. Key central moments: +-------+-----------------------+-----------------------------------------+ | Order | Central moment | Interpretation | +=======+=======================+=========================================+ | r = 1 | :math:`\mu_1 = 0` | Always zero by definition of mean | +-------+-----------------------+-----------------------------------------+ | r = 2 | :math:`\mu_2` | **Variance** sigma^2 | +-------+-----------------------+-----------------------------------------+ | r = 3 | :math:`\mu_3` | Raw material for skewness | +-------+-----------------------+-----------------------------------------+ | r = 4 | :math:`\mu_4` | Raw material for kurtosis | +-------+-----------------------+-----------------------------------------+ Moments about a Custom Point (a = c) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For any constant :math:`c`, the moment about :math:`c` interpolates between raw moments (c = 0) and central moments (c = μ). This is useful when a distribution's natural reference point differs from both. ---- Relationships Between Moment Types ------------------------------------ Central moments can be expressed in terms of raw moments using the binomial theorem: .. math:: \mu_r = \sum_{k=0}^{r} \binom{r}{k} (-\mu)^{r-k} \mu'_k The first few expansions: .. math:: \mu_2 = \mu'_2 - (\mu'_1)^2 = E[X^2] - (E[X])^2 .. math:: \mu_3 = \mu'_3 - 3\mu'_2\mu'_1 + 2(\mu'_1)^3 .. math:: \mu_4 = \mu'_4 - 4\mu'_3\mu'_1 + 6\mu'_2(\mu'_1)^2 - 3(\mu'_1)^4 ToFUL does not use these formulae internally — it computes each moment type directly from the definition, which avoids catastrophic cancellation for large or broad distributions. ---- Existence of Moments --------------------- Not all distributions have finite moments of all orders. A moment of order :math:`r` exists (is finite) if and only if :math:`E[|X|^r] < \infty`. For distributions with heavy tails, high-order moments may be infinite: * **Cauchy distribution** — no finite moments of any order. * **Pareto distribution** — moments of order :math:`r \geq \alpha` are infinite, where :math:`\alpha` is the tail index. * **Student-t with ν degrees of freedom** — moments of order :math:`r \geq \nu` are infinite. When a moment does not exist, the integration or sum will either return a very large number or fail to converge. The Convergence tab will report the method as ``partial-sum`` with a note about divergence. ---- Moment Generating Function --------------------------- The *moment generating function* (MGF) of X is: .. math:: M_X(t) = E\left[e^{tX}\right] When it exists in a neighbourhood of :math:`t = 0`, the raw moments are obtained by differentiation: .. math:: \mu'_r = M_X^{(r)}(0) = \left.\frac{d^r}{dt^r} M_X(t)\right|_{t=0} ToFUL does not use MGFs directly, but the SymPy symbolic path essentially performs the equivalent symbolic integration. ---- Standardised Moments --------------------- The *standardised r-th moment* divides the central moment by the appropriate power of the standard deviation: .. math:: \tilde{\mu}_r = \frac{\mu_r}{\sigma^r} The two most commonly standardised moments are skewness (:math:`\tilde{\mu}_3`) and kurtosis (:math:`\tilde{\mu}_4`). See :doc:`skewness-kurtosis` for a detailed treatment. See also -------- * :doc:`raw-vs-central` — choosing between raw and central moments * :doc:`skewness-kurtosis` — shape characterisation via standardised moments * :doc:`convergence` — how ToFUL evaluates the sums and integrals