# Is $\bar X$ a random variable or a constant?

I am confused how $$\bar X$$ is used sometimes as a constant and othertimes as a random variable.

My understanding is that $$\bar X$$ is a random variable because it changes every time our sample changes. I also understand that $$E[\bar X]= E[\frac{X_1 +X_2 +...+X_n}{n}]=\frac{ nE[X]}{n} = E[X] = \mu$$

I get confused when the professor writes $$\bar{X}=E[\bar X]= E[\frac{X_1 +X_2 +...+X_n}{n}]=\frac{ nE[X]}{n} = E[X] = \mu$$ and when he uses $$\sum_1^n \bar X = n \bar X$$ to proove another equation wich is $$(X_i-\bar X)^2=\sum_1^nX_i^2-n\bar X^2$$.

Someone can explain me this please? thank you

• The only problematic equation is "$\bar X = E[\bar X]$." If your professor wrote that, you should ask them what they meant by such a circular expression. Everything else is just algebraic manipulation or exploitation of the linearity of expectation. – whuber Sep 26 '18 at 17:31
• But I think $\sum_1^n\bar X = n \bar X$ is not just algebraic manipulation or exploitation of the linearity of expectation. It means that he considered $\bar X$ constant. Isn't it? – Youssef Sep 26 '18 at 17:35
• No, it's pure algebra. Please read stats.stackexchange.com/questions/95993. – whuber Sep 26 '18 at 17:36
• I red it . How $\bar X$ is always the same for i= 1, 2 ---, n if it is a random variable ? – Youssef Sep 26 '18 at 17:42
• "$\sum_{i=1}^n \text{anything}$" always means to sum $\text{anything}$ $n$ times, giving $n$ times $\text{anything}.$ – whuber Sep 26 '18 at 18:04

Assume $$X_i$$ is a random variable. Then, $$\bar X$$, defined as $$\frac{1}{n}\sum_{i=1}^n X_i$$, is also a random variable. For each realisation of the sample, it will have a different value.

As stated in @whuber's comment, $$\bar X$$ is not equal to $$E(\bar X)$$ in general.

To answer the last comment/question: $$\bar X$$ does not vary as a function of $$i$$ but it varies as a function of the sample. Therefore, it is true that $$\sum_{i=1}^n \bar X = n \bar X$$, while $$\bar X$$ is still a random variable. Take a different sample of $$n$$ individuals, you can define $$\bar X$$, it will have a different value and still, $$\sum_{i=1}^n \bar X = n \bar X$$ will hold.

You'll find that the sample expected value of the expected value of a random variable is a constant, the population mean $$\mu$$.

$$\mathbf E[\mathbf E[X]]=\mathbf E[\bar X]=\mu$$

$$\mathbf E[\bar X]$$ is your estimation of $$\mu$$, but it's a random variable because it's derived from a sample estimate.

Following the same logic, $$\bar X=\mathbf E[X]$$ is not a constant, but also a random variable.