# Calculating sample size from a distribution with an unknown mean

I'm trying to read through DeGroot's Probability and Statistics and my progress has slowed in Chapter 7. DeGroot makes the following definition:

For any random variable $$Z = g(X_1, ..., X_n)$$, we shall let $$E_\theta(Z)$$ denote the expectation of Z calculated with respect to the joint p.d.f. or joint p.f. $$f_n(\mathbf{x} | \theta)$$. Thus if $$f_n(\mathbf{x} | \theta)$$ is a p.d.f.,

$$E_\theta(Z) = \int_{-\infty}^\infty \cdot\cdot\cdot\int_{-\infty}^\infty g(\mathbf{x})f_n(\mathbf{x} | \theta) ~ dx_1 \cdot\cdot\cdot dx_n$$

In other words, $$E_\theta(Z)$$ is the expectation of $$Z$$ for a given value of $$\theta ~\epsilon~ \Omega$$. Now consider the following exercises:

1. Suppose that a random sample is to be taken from a normal distribution for which the value of the mean $$\theta$$ is unknown and the standard deviation is $$2$$. How large a random sample must be taken in order that $$E_\theta(|\bar{X}_n - \theta|^2) \leq 0.1$$ for every possible value of $$\theta$$?

2. For the conditions of Exercise 1, how large a random sample must be taken in order that $$E_\theta(|\bar{X}_n - \theta|) \leq 0.1$$ for every possible value of $$\theta$$?

The solution to exercise 2 reads:

Once again, $$\bar{X}_n$$ has the normal distribution with mean $$\theta$$ and variance $$4 /n$$. Hence, the random variable $$Z = (\bar{X}_n - \theta) / (2 / \sqrt{n})$$ will have the standard normal distribution. Therefore,

$$E_\theta(|\bar{X}_n - \theta|) = {2 \over \sqrt{n}} E_\theta( | Z|) = {2 \over \sqrt{n}} \int_{-\infty}^\infty |z| {1\over \sqrt{2\pi}} e^{- {z^2 \over 2}} dz = 2 \sqrt{{2 \over {n\pi}}}$$

From which the problem can be finished in the obvious way. My confusion arises at the second equality in the computations above, namely the implication that:

$$E_\theta( |Z|) = \int_{-\infty}^\infty |z| {1\over \sqrt{2\pi}} e^{- {z^2 \over 2}} dz$$

which seems (in my mind) to directly contradict the definition of $$E_\theta(Z)$$ provided above. I don't know what theorem I'm forgetting from multivariable calculus that establishes the equivalence of these integrations.

Some clarity here would be very helpful. Thank you.

I've realized one mistake that was causing me confusion. To get a sense of the problem I was considering the case $n = 2$, and so proceeding naively from the definition I wrote:

\begin{align} E_\theta(|\bar{X}_2 - \theta|) &= {\int\int}_{\Bbb{R}^2} \left ({x_1 + x_2} \over 2 \right) f_2(x_1, x_2 | \theta)~ dA \\ &= {1 \over 2} {\int\int}_{\Bbb{R}^2} [x_1 f(x_1 | \theta)]\cdot f(x_2 | \theta) + [x_2 f(x_2 | \theta)]\cdot f(x_1 | \theta) ~dx_1 dx_2 \\ &= {1 \over 2} \int_\Bbb{R} \left( \int_\Bbb{R} [x_1 f(x_1 | \theta)]\cdot f(x_2 | \theta)~ dx_1 + \int_\Bbb{R} [x_2 f(x_2 | \theta)]\cdot f(x_1 | \theta)~ dx_1 \right) ~ dx_2 \\ &= {1 \over 2} \int_\Bbb{R} \left( f(x_2 | \theta)\cdot \int_\Bbb{R} [x_1 f(x_1 | \theta)]~ dx_1 + [x_2 f(x_2 | \theta)]\cdot \int_\Bbb{R}f(x_1 | \theta)~ dx_1 \right) ~ dx_2 \\ &= {1 \over 2} \int_\Bbb{R} f(x_2 | \theta)\cdot E(X_1) + [x_2 f(x_2 | \theta)] \cdot 1 ~dx_2 \\ &= {1 \over 2} \left[ E(X_1) \cdot \int_\Bbb{R} f(x_2 | \theta) ~dx_2 + \int_\Bbb{R} x_2 f(x_2 | \theta) ~dx_2 \right ] \\ &= {1 \over 2} \left [E(X_1) \cdot 1 + E(X_2) \right] \\ &= \theta \end{align}

I now realize there are at least 2 mistakes being made:

1. I neglected absolute values
2. I neglected $\theta$!

Specifically, I should've started with:

$$E_\theta (|\bar{X}_n - \theta|) = {\int\int}_{\Bbb{R}^2} \left |{{x_1 + x_2} \over 2} - \theta \right| f_2(x_1, x_2 | \theta)~ dA$$

and proceeded this way, but this integrand makes me want to find an alternative approach

I was browsing around SE looking for inspiration, and another problem got me thinking about the expression $$P[ (\bar{X}_n - \theta ) \leq c\sigma ] = P \left[ {\left( \bar{X}_n - \theta \over {\sigma}\right )} \leq c \right] = P(Z \leq c) = \Phi(c)$$

I think this means that if $F$ is the c.d.f. of the variable $\bar{X}_n - \theta$, then $F(x) = \Phi(x / \sigma)$, which justifies switching to the standard normal variable to compute $E_\theta(|Z|)$.