Can a random variable/distribution have non-constant mean?

I have been asked that question, and it's very weird to me. I know how a random variable/distribution can basically not have a mean due to diverging integral of its expected value.

But how is it possible that the mean of a random variable "exists"/can be defined, but not be stable? What are some examples of such distributions?

• $Y\sim N(\mu,\sigma_1^2)$ and $\mu \sim N(0,\sigma_2^2)$. Then mean of $Y$ is unstable. Commented Aug 12, 2019 at 5:40
• Distributions can be contingent on more than one variable. For example, the joint density to find an object at position $x$ at time $t$ can be denoted $p(x,t)$. Then the mean position of the object $\langle x(t) \rangle = \int x p(x,t)dx$ is generally a function of time as opposed to constant. Commented Aug 12, 2019 at 6:21
• @user158565 That example has a straightforward mean that we get by integrating out $\mu$ and \$\sigma_2)? The example by kevinkayaks makes more sense to me - i.e. the mean is determined by some other things that change. Commented Aug 12, 2019 at 7:11
• The mathematical definitions imply the expectation is a number or does not exist. Any other answer has to modify the usual sense (either explicitly or implicitly) of "random variable."
– whuber
Commented Aug 12, 2019 at 12:32
• @whuber what wouls you say to the above about the mean of the posterior predicitve distribution? Commented Aug 14, 2019 at 10:07

Yes it can. In fact this is crucial in Bayesian Analysis where we are modeling something according to some distribution but we are unsure of paramaters in it. Exactly like user158565 commented. In his case, if we want to sample from Y, we first sample a mean from $$\mu$$'s distribution, then using that we sample a Y by the distribution defined by this $$\mu$$. We can keep nesting distributions one after the other like this!