If $X$ is a random variable and $x$'s are the realizations form $X$ and

  • $N$ is the population size

  • $n$ is the sample size

Which one is correct

  • $\mathbb E(X)=\sum_{i=1}^{N}x_i P(x_i)$


  • $\mathbb E(X)=\sum_{i=1}^{n}x_i P(x_i)$ .

I know the latter is the correct one . But don't know why ?

  • 1
    $\begingroup$ What is $x_i$ and what is $P(x_i)?$ $\endgroup$
    – KOE
    Apr 28, 2015 at 11:37
  • $\begingroup$ @Student001 Please see the edit . $\endgroup$
    – ABC
    Apr 28, 2015 at 11:38
  • 3
    $\begingroup$ This question is vague and looks like it's leading to contradictory answers. I think the vagueness is located in the meaning of "realization." When one has $N$ realizations of a random variable that models a finite population of size $N$, many of those values are duplicates: the set of $N$ realizations is still just a sample of size $N$, not the entire population. In these standard senses of terms "realization," "sample," and "population," neither expression is correct. Could you therefore please edit this question to explain what you mean by "realization"? $\endgroup$
    – whuber
    Apr 28, 2015 at 14:33
  • 1
    $\begingroup$ $P(x_i)$ is still undefined. And, frankly, I don't think either formula is correct. The summation should only be over the unique values of $x_i$, rather than the population or the sample (unless you define $P(a)=\sum_{i=1}^N 1\{x_i=a\}/N$, in which case the population formula is the right one). $\endgroup$
    – StasK
    Apr 28, 2015 at 21:52

4 Answers 4


The summation with $N$ is the true population mean, and the summation with $n$ is the sample mean. The "correct one" is actually the true population mean. It's just that in most cases you don't have access to the entire population of data (that would be very nice). You usually only have access to a small sample of that data. So we use the sample mean as our best estimate of the true population mean.


I think the answer to your question is the first option. In both cases, your options describe a mean, which is an expected value.

For this to work, $ P(x)$ must be the probability distribution of $x$. If we know all $ x_i \in X $, then the population mean, $\mu = \sum_{i=1}^{N} x_i \cdot P(x_i)$. As @neoFox and @andrew have pointed out, it is often impossible or impractical to obtain the entire population and instead we draw a sample.

After drawing a sample of size $n$, then $E(\bar{X}) = \sum_{i=1}^{n} x_i \cdot P(x_i) $. This is a sample mean, and only approximates the population mean of $X$, $E(X)$, and will most likely be different from $E(X)$ in reality.

  • 1
    $\begingroup$ The final line appears to abuse notation: $E(X)$ refers to the expectation of $X$, which usually is not the sample mean. The first equality therefore is incorrect. $\endgroup$
    – whuber
    Apr 28, 2015 at 14:31
  • $\begingroup$ Thanks, I hit submit too soon, but I have corrected the notation. $\endgroup$
    – user32490
    Apr 28, 2015 at 14:32
  • 1
    $\begingroup$ Unfortunately your new effort is confusing and incorrect. If by "$E(Y)$" you intend the mean of the sample (which usually would be written $E(\bar Y)$), then $E(Y)$ equals the mean of the population, which still usually differs from the mean of the sample itself. $\endgroup$
    – whuber
    Apr 28, 2015 at 14:35

Neither one is correct. The expected value of X (in the discrete case) can be thought of as a weighted average. You sum over all of the values that X can take on, and multiply that by the probability of X = x (P(x)) occurring.

$\mathbb E(X)=\sum_{x} x P(x)$

If you want an estimate the mean from a sample, then the sample average is appropriate. If you have the population then:

$\mathbb E(X)= \mu = N^{-1} \sum_{i = 1}^N x_i$

  • 1
    $\begingroup$ Are you stating that the right hand sides of the two formulas are equivalent? (That is algebraically implied by the identity of their left hand sides.) If so, then aren't you implying that $P(x)=1/N$ for all $x$ in the population? $\endgroup$
    – whuber
    Apr 28, 2015 at 14:42
  • $\begingroup$ No. In the first equation you are summing over all the possible values possible for a random variable, X, weighted by the probability of the variable taking on the value. In the second you are summing over all the values taken on by the members of the population. If $X \in (0, 1)$ and $p(X = 1) = p(X = 0) = 0.5$ then $\mathbb{E}(X) = 0.5(1) + 0.5(0) = 0.5$ vs. if there are 1000 people in the POPULATION (not sample) and 50% of them are 1's and the other 50% 0's then $\mathbb{E}(X) = \frac{50}{100} = 0.5$ $\endgroup$
    – sm1116
    Apr 30, 2015 at 20:32
  • $\begingroup$ This appears to reflect some confusion between a population and a random variable. The vagueness of the domain of the first sum contributes to that and using the same symbol "$X$" in both expressions reinforces it. $\endgroup$
    – whuber
    Apr 30, 2015 at 22:05

The size of population is $N$. Let the mean of the population distribution be $\mu$. Consider that we have no information about the population distribution or it's mean. Now we are given a sample from the population($x_i$) of size n and its distribution($P(x_i)$). $$\sum_{i=1}^n x_i P(x_i)$$ is the estimator of the mean of the population, estimated using the given sample.

  • $\begingroup$ This is false. The sample mean is $\frac{1}{n} \sum_{i=1}^n x_i$. If you include the $P()$ inside the summation, you're effectively double-counting it, since the frequency of occurrence of the possible values of $x$ itself depends on $P(x)$. $\endgroup$
    – Hong Ooi
    Apr 28, 2015 at 16:25
  • $\begingroup$ sample mean is $\frac{1}{n} \sum_{n=1}^n x_i$ when the population follows a uniform distribution. In that case $P(x_i) = \frac{1}{n}$. In $\sum_{i=1}^n x_i P(x_i)$ there is no double counting because i am not dividing the summation by n. In general, population can follow any distribution for example a normal distribution. So you will have to include the probability inside the summation. Probability outside the summation would be meaningless when the distribution is not uniform. $\endgroup$
    – kanatti
    Apr 28, 2015 at 18:30

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.