48
$\begingroup$

What is the rule for computing $ \text{E}[X^{2}] $, where $ \text{E} $ is the expectation operator and $ X $ is a random variable?

Let $ S $ be a sample space, and let $ p(x) $ denote the probability mass function of $ X $.

Is $$ \text{E}[X^{2}] = \sum_{x \in S} x^{2} \cdot p(x), $$ or do I also need to square the $ x $ appearing in $ p(x) $?

$\endgroup$
6
  • 3
    $\begingroup$ Yes, that's it (as long as $X$ is discrete). $\endgroup$ Feb 18, 2013 at 0:47
  • 2
    $\begingroup$ Yes, this is called second moment. $\endgroup$
    – Alex
    Feb 18, 2013 at 0:48
  • $\begingroup$ See math.stackexchange.com/questions/306425/expected-value-function $\endgroup$
    – user940
    Feb 18, 2013 at 2:14
  • $\begingroup$ Dear CodeKingPlusPlus, you have to be a little careful with the formula that you’ve written down. The variable $ x $ should only take values in the range of the random variable $ X $. Just because $ X $ is discrete doesn’t mean that the sample space $ \Omega $ is finite or countably infinite. :) $\endgroup$ Feb 18, 2013 at 7:01
  • $\begingroup$ Apart from that, the formula is correct! There’s no need to square the $ x $ in the expression $ p(x) $. $\endgroup$ Feb 18, 2013 at 7:04

1 Answer 1

36
$\begingroup$

In general, if $ (\Omega,\Sigma,P) $ is a probability space and $ X: (\Omega,\Sigma) \to (\mathbb{R},\mathcal{B}(\mathbb{R})) $ is a real-valued random variable, then $$ \text{E}[X^{2}] = \int_{\Omega} X^{2} ~ d{P}. $$ Although this formula works for all cases, it is rarely used, especially when $ X $ is known to have certain nice properties.

Examples:

  • If $ X $ is a discrete random variable (i.e., its cumulative distribution function (cdf) is a step-function) and $ p $ is its probability mass function (pmf), then we can use the formula $$ \text{E}[X^{2}] = \sum_{x \in \text{Range}(X)} x^{2} \cdot p(x). $$

  • If $ X $ is an absolutely continuous random variable (i.e., its cdf is an absolutely continuous function), then it possesses a probability density function (pdf) $ f $. We thus have the formula $$ \text{E}[X^{2}] = \int_{\mathbb{R}} x^{2} f(x) ~ d{\mu(x)}, $$ where $ \mu $ is the standard Borel measure on $ \mathbb{R} $. Of course, if $ f $ is continuous, then we can simply compute the improper Riemann integral $$ \text{E}[X^{2}] = \int_{- \infty}^{\infty} x^{2} f(x) ~ d{x}. $$

$\endgroup$
2
  • $\begingroup$ The random variable is defined as mapping b/w sample space and real number. What is the role of events($\Sigma$) in random variable ? $\endgroup$ Apr 6, 2020 at 6:18
  • $\begingroup$ Events are subsets of the sample space. $\endgroup$
    – MSIS
    Apr 17, 2020 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .