et a standardized or vice versa - ``'quadrature'``: numerically integrate according to the definition Not all `method` options are available for all orders, kinds, and distributions. If the selected `method` is not available, a ``NotImplementedError`` will be raised. Returns ------- out : array The moment of the random variable of the specified order and kind. See Also -------- pdf mean variance standard_deviation skewness kurtosis Notes ----- Not all distributions have finite moments of all orders; moments of some orders may be undefined or infinite. If a formula for the moment is not specifically implemented for the chosen distribution, SciPy will attempt to compute the moment via a generic method, which may yield a finite result where none exists. This is not a critical bug, but an opportunity for an enhancement. The definition of a raw moment in the summary is specific to the raw moment about the origin. The raw moment about any point :math:`a` is: .. math:: E[(X-a)^n] = \int_{\chi} (x-a)^n f(x) dx In this notation, a raw moment about the origin is :math:`\mu'_n = E[x^n]`, and a central moment is :math:`\mu_n = E[(x-\mu)^n]`, where :math:`\mu` is the first raw moment; i.e. the mean. The ``'transform'`` method takes advantage of the following relationships between moments taken about different points :math:`a` and :math:`b`. .. math:: E[(X-b)^n] = \sum_{i=0}^n E[(X-a)^i] {n \choose i} (a - b)^{n-i} For instance, to transform the raw moment to the central moment, we let :math:`b = \mu` and :math:`a = 0`. The distribution infrastructure provides flexibility for distribution authors to implement separate formulas for raw moments, central moments, and standardized moments of any order. By default, the moment of the desired order and kind is evaluated from the formula if such a formula is available; if not, the infrastructure uses any formulas that are available rather than resorting directly to numerical integration. For instance, if formulas for the first three raw moments are available and the third standardized moments is desired, the infrastructure will evaluate the raw moments and perform the transforms and standardization required. The decision tree is somewhat complex, but the strategy for obtaining a moment of a given order and kind (possibly as an intermediate step due to the recursive nature of the transform formula above) roughly follows this order of priority: #. Use cache (if order of same moment and kind has been calculated) #. Use formula (if available) #. Transform between raw and central moment and/or normalize to convert between central and standardized moments (if efficient) #. Use a generic result true for most distributions (if available) #. Use quadrature References ---------- .. [1] Moment, *Wikipedia*, https://en.wikipedia.org/wiki/Moment_(mathematics) Examples -------- Instantiate a distribution with the desired parameters: >>> from scipy import stats >>> X = stats.Normal(mu=1., sigma=2.) Evaluate the first raw moment: >>> X.moment(order=1, kind='raw') 1.0 >>> X.moment(order=1, kind='raw') == X.mean() == X.mu True Evaluate the second central moment: >>> X.moment(order=2, kind='central') 4.0 >>> X.moment(order=2, kind='central') == X.variance() == X.sigma**2 True Evaluate the fourth standardized moment: >>> X.moment(order=4, kind='standardized') 3.0 >>> X.moment(order=4, kind='standardized') == X.kurtosis(convention='non-excess') True r