X is a uniform random variable on $[n]=\{1,2,\dots ,n\}$ and for every $i\in[n]$ We define$ Y_i \sim Ber(\frac{1}{2})$ ,such that all The variables are independent(all The Y's and X). now we have to calculate the following expectations:
$$a_{1}=\mathbb{E}[\sum_{i\le X}Y_{i}|Y_{1}=Y_{2}=\dots=Y_{X}=1]$$
and
$$a_{2}=\mathbb{E}[\sum_{i\le X}Y_{i}]$$
And after you calculate the expected values, you have to explain why for large $n$ we get that $a_{1}$ is much smaller than $a_{2}$.
The problem is that I got that $a_1>a_2$, always, like this:
$$a_{1}=\mathbb{E}[\sum_{i\le X}Y_{i}|Y_{1}=Y_{2}=\dots=Y_{X}=1]\stackrel{\text{adds 1 X times}}{=}\mathbb{E}[X]=\frac{n+1}{2}$$
$$a_{2}=\mathbb{E}[\sum_{i\le X}Y_{i}]=\sum_{k=1}^{n}\mathbb{E}[\sum_{i\le X}Y_{i}\vert X=k]\cdot\mathbb{P}(X=k)=\sum_{k=1}^{n}\mathbb{E}[\sum_{i\le k}Y_{i}]\cdot\mathbb{P}(X=k)$$
$$=\frac{1}{n}\cdot\sum_{k=1}^{n}\sum_{i=1}^{k}\mathbb{E}[Y_{i}]=\frac{1}{n}\cdot\sum_{k=1}^{n}\frac{k}{2}=\frac{1}{2n}\cdot\frac{n(n+1)}{2}=\frac{n+1}{4}$$
And $\frac{n+1}{2}>\frac{n+1}{4}$, always.
Does anyone have any idea what I am doing wrong?
Thanks in advance.
This question was given as homework.
Your error is in $a_{1}=\mathbb{E}[\sum_{i\le X}Y_{i}\mid Y_{1}=Y_{2}=\dots=Y_{X}=1]\stackrel{\text{adds 1 X times}}{=}\mathbb{E}[X]$ as you are taking the conditional expectations in the wrong order. Assuming independence:
As an illustration when $n=2$, you have
which is not your $\frac{n+1}{2}=\frac32$