Suppose I have given a finite number of grid values belonging to a probability density function. Moreover, I have the associated values of the density support. For instance:

support density value
0.06    0.07
-0.04   0.11
-0.02   0.52
0.00    1.56
0.02    7.87
0.04    19.18
0.06    13.66
0.08    3.40
0.10    0.98
0.13    0.33
0.15    0.14
0.17    0.07
0.19    0.00
0.22    0.43
0.24    0.01

Does anyone know the formula to calculate the first four moments of the distribution?

I would appreciate any help. Many thanks in advance!

  • 2
    $\begingroup$ You could interpolate the density and then numerically integrate this function? You know, $E[X]=\int_\mathbb{R} xf_X(x)dx$ etc... $\endgroup$
    – Alex
    Jul 4, 2020 at 13:15

2 Answers 2


The key is:

$$ \mathbf{E}[X^k] = \sum_{i=1}^n x_i^k p(x_i) $$

($X$ discrete variable, $x_i$ realizations, and $p(x_i)$ realization probabilities)

See this link for further details.

  • $\begingroup$ Great, this helps a lot! thanks! $\endgroup$
    – Walter
    Jul 4, 2020 at 13:27
  • 1
    $\begingroup$ @Walter Glad to help. Unless you are waiting for other answers, please consider marking this answer as accepted (marking procedure available here: stackoverflow.com/help/someone-answers) $\endgroup$
    – ir7
    Jul 4, 2020 at 13:35
  • 1
    $\begingroup$ As the densities do not yet sum to one, please also consider proper normalisation, no? $\endgroup$ Jul 5, 2020 at 6:29
  • $\begingroup$ @Kermittfrog Good point. If they don’t add up to one, one needs to normalize them. See, for example, math.stackexchange.com/questions/278418/… $\endgroup$
    – ir7
    Jul 5, 2020 at 16:45

Just to add, you did not mention which kind of momement. These calculated by formula in ir7 are called general moments. However, there are also:

  • Central moments defined as $E[X-EX]^k$
  • Standardized moments defined as $E\big[\frac{X-EX}{\sigma(X)}\big]^k$,

where $EX$ is first general moment (expected value) and $\sigma(X)$ is second general moment (standard deviation).

Note that for $k=1$ the central moment and standardized moment are always 0. For $k=2$, the standardized moment is always 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.