Can expectation of a random variable be a random variable

expected valueprobabilityrandom variables

Suppose I have, $$ X = 1$$ with probability $p$ and $$X=0$$ otherwise.
Now, if $p$, in turn, is a random variable (for example, let's say it takes a value from 0 to 1 uniformly at random), what is $\Bbb E[X]$?
Is it just $p$ or $\Bbb E[p]$?

I took some examples (with a dice) and that makes me think that it is $\Bbb E[p]$. Also, as the expectation is constant, I think it cannot be just $p$. But, I am not sure if my logic is correct. I tried looking into this, but the answers I see either involve a lot of measure theory (which I don't know) or are not exactly related to my question.

I apologize if the question is not clear, I can give any extra details that you consider necessary.

Edit: I am not sure if this is the right way to edit and continue a question with a follow-up, but I have an additional question now.

For the example mentioned here, can I instead write $$X=1$$ with probability $E[p]$ and $$X= 0$$ otherwise?

Thanks in advance!

Best Answer

In this case we have $X\sim \text{Bernoulli}(p)$ where $p$ is a random variable. We have \begin{align*} \mathbb E(X|p)&= p\\ \mathbb E(X) &= \mathbb E(\mathbb E(X|p)) = \mathbb E(p) \end{align*} which is a constant, not a random variable.

Related Question