# Does Bayes theorem hold for expectations?

Is it true that for two random variables $A$ and $B$,

$$E(A\mid B)=E(B\mid A)\frac{E(A)}{E(B)}?$$

• Hmm...I do not think those two sides are equivalent
– Jon
Feb 9, 2017 at 16:45
• As pointed out in the answers, the question is probabilistically meaningless because of the integration of random variables on one side that are the conditioning variables on the other side. Feb 9, 2017 at 17:57

$$E[A\mid B] \stackrel{?}= E[B\mid A]\frac{E[A]}{E[B]} \tag 1$$ The conjectured result $(1)$ is trivially true for independent random variables $A$ and $B$ with nonzero means.

If $E[B]=0$, then the right side of $(1)$ involves a division by $0$ and so $(1)$ is meaningless. Note that whether or not $A$ and $B$ are independent is not relevant.

In general, $(1)$ does not hold for dependent random variables but specific examples of dependent $A$ and $B$ satisfying $(1)$ can be found. Note that we must continue to insist that $E[B]\neq 0$, else the right side of $(1)$ is meaningless. Bear in mind that $E[A\mid B]$ is a random variable that happens to be a function of the random variable $B$, say $g(B)$ while $E[B\mid A]$ is a random variable that is a function of the random variable $A$, say $h(A)$. So, $(1)$ is similar to asking whether

$$g(B)\stackrel{?}= h(A)\frac{E[A]}{E[B]} \tag 2$$ can be a true statement, and obviously the answer is that $g(B)$ cannot be a multiple of $h(A)$ in general.

To my knowledge, there are only two special cases where $(1)$ can hold.

• As noted above, for independent random variables $A$ and $B$, $g(B)$ and $h(A)$ are degenerate random variables (called constants by statistically-illiterate folks) that equal $E[A]$ and $E[B]$ respectively, and so if $E[B]\neq 0$, we have equality in $(1)$.

• At the other end of the spectrum from independence, suppose that $A=g(B)$ where $g(\cdot)$ is an invertible function and thus $A=g(B)$ and $B=g^{-1}(A)$ are wholly dependent random variables. In this case, $$E[A\mid B] = g(B), \quad E[B\mid A] = g^{-1}(A) = g^{-1}(g(B)) = B$$ and so $(1)$ becomes $$g(B)\stackrel{?}= B\frac{E[A]}{E[B]}$$ which holds exactly when $g(x) = \alpha x$ where $\alpha$ can be any nonzero real number. Thus, $(1)$ holds whenever $A$ is a scalar multiple of $B$, and of course $E[B]$ must be nonzero (cf. Michael Hardy's answer). The above development shows that $g(x)$ must be a linear function and that $(1)$ cannot hold for affine functions $g(x) = \alpha x + \beta$ with $\beta \neq 0$. However, note that Alecos Papadopolous in his answer and his comments thereafter claims that if $B$ is a normal random variable with nonzero mean, then for specific values of $\alpha$ and $\beta\neq 0$ that he provides, $A=\alpha B+\beta$ and $B$ satisfy $(1)$. In my opinion, his example is incorrect.

In a comment on this answer, Huber has suggested considering the symmetric conjectured equality $$E[A\mid B]E[B] \stackrel{?}=E[B\mid A]E[A]\tag{3}$$ which of course always holds for independent random variables regardless of the values of $E[A]$ and $E[B]$ and for scalar multiples $A = \alpha B$ also. Of course, more trivially, $(3)$ holds for any zero-mean random variables $A$ and $B$ (independent or dependent, scalar multiple or not; it does not matter!): $E[A]=E[B]=0$ is sufficient for equality in $(3)$. Thus, $(3)$ might not be as interesting as $(1)$ as a topic for discussion.

• +1. To be generous, the question could be interpreted as asking whether $E(A|B)E(B)=E(B|A)E(A)$, where the question of division by zero disappears.
– whuber
Feb 9, 2017 at 16:56
• @whuber Thanks. My edit addresses the more general question as to whether it is possible to have $E[A\mid B]E[B]=E[B\mid A]E[A]$. Feb 9, 2017 at 17:02

The result is untrue in general, let us see that in a simple example. Let $X \mid P=p$ have a binomial distribution with parameters $n,p$ and $P$ have the beta distrubution with parameters $(\alpha, \beta)$, that is, a bayesian model with conjugate prior. Now just calculate the two sides of your formula, the left hand side is $\DeclareMathOperator{\E}{\mathbb{E}} \E X \mid P = nP$, while the right hand side is $$\E( P\mid X) \frac{\E X}{\E P} = \frac{\alpha+X}{n+\alpha+\beta} \frac{\alpha/(\alpha+\beta)}{n\alpha/(\alpha+\beta)}$$ and those are certainly not equal.

The conditional expected value of a random variable $A$ given the event that $B=b$ is a number that depends on what number $b$ is. So call it $h(b).$ Then the conditional expected value $\operatorname{E}(A\mid B)$ is $h(B),$ a random variable whose value is completely determined by the value of the random variable $B$. Thus $\operatorname{E}(A\mid B)$ is a function of $B$ and $\operatorname{E}(B\mid A)$ is a function of $A$.

The quotient $\operatorname{E}(A)/\operatorname{E}(B)$ is just a number.

So one side of your proposed equality is determined by $A$ and the other by $B$, so they cannot generally be equal.

(Perhaps I should add that they can be equal in the trivial case when the values of $A$ and $B$ determine each other, as when for example, $A = \alpha B, \alpha \neq 0$ and $E[B]\neq 0$, when $$E[A\mid B] = \alpha B = E[B\mid A]\cdot\alpha = E[B\mid A]\frac{\alpha E[B]}{E[B]} = E[B\mid A]\frac{E[A]}{E[B]}.$$ But functions equal to each other only at a few points are not equal.)

• You mean they are not necessarily equal? I mean they CAN be equal?
– BCLC
Feb 9, 2017 at 19:06
• @BCLC : They are equal only in trivial cases. And two functions equal to each other at some points and not at others are not equal. Feb 9, 2017 at 21:50
• "But only in that trivial case can they be equal" (emphasis added) is not quite correct. Consider independent $A$ and $B$ with $E[B]\neq 0$. Then, $E[A\mid B] = E[A]$ while $E[B\mid A] = E[B]$ and so $$E[B\mid A] \frac{E[A]}{E[B]} = E[B]\frac{E[A]}{E[B]} = E[A] = E[A\mid B].$$ Feb 9, 2017 at 23:08
• @DilipSarwate I was about to say that haha!
– BCLC
Feb 10, 2017 at 3:36
• I edited your answer to add a few details for the case you pointed out. Please roll back if you don't like the changes. Feb 11, 2017 at 15:12

The expression certainly does not hold in general. For the fun of it, I show below that if $A$ and $B$ follow jointly a bivariate normal distribution, and have non-zero means, the result will hold if the two variables are linear functions of each other and have the same coefficient of variation (the ratio of standard deviation over mean) in absolute terms.

For jointly normals we have

$$\operatorname{E}(A \mid B) = \mu_A + \rho \frac{\sigma_A}{\sigma_B}(B - \mu_B)$$

and we want to impose

$$\mu_A + \rho \frac{\sigma_A}{\sigma_B}(B - \mu_B) = \left[\mu_B + \rho \frac{\sigma_B}{\sigma_A}(A - \mu_A)\right]\frac{\mu_A}{\mu_B}$$

$$\implies \mu_A + \rho \frac{\sigma_A}{\sigma_B}(B - \mu_B) = \mu_A + \rho \frac{\sigma_B}{\sigma_A}\frac{\mu_A}{\mu_B}(A - \mu_A)$$

Simplify $\mu_A$ and then $\rho$, and re-arrange to get

$$B = \mu_B +\frac{\sigma^2_B}{\sigma^2_A}\frac{\mu_A}{\mu_B}(A - \mu_A)$$

So this is the linear relationship that must hold between the two variables (so they are certainly dependent, with correlation coefficient equal to unity in absolute terms) in order to get the desired equality. What it implies?

First, it must also be satisfied that

$$E(B) \equiv \mu_B = \mu_B+\frac{\sigma^2_B}{\sigma^2_A}\frac{\mu_A}{\mu_B}(E(A) - \mu_A) \implies \mu_B = \mu_B$$

so no other restirction is imposed on the mean of $B$ ( or of $A$) except of them being non-zero. Also a relation for the variance must be satisfied,

$$\operatorname{Var}(B) \equiv \sigma^2_B = \left(\frac{\sigma^2_B}{\sigma^2_A}\frac{\mu_A}{\mu_B}\right)^2\operatorname{Var}(A)$$

$$\implies \left(\sigma^2_A\right)^2\sigma^2_B = \left(\sigma^2_B\right)^2\sigma^2_A\left(\frac{\mu_A}{\mu_B}\right)^2$$

$$\implies \left(\frac{\sigma_A}{\mu_A}\right)^2 = \left(\frac{\sigma_B}{\mu_B}\right)^2 \implies (\text{cv}_A)^2 = (\text{cv}_B)^2$$

$$\implies |\text{cv}_A| = |\text{cv}_B|$$

which was to be shown.

Note that equality of the coefficient of variation in absolute terms, allows the variables to have different variances, and also, one to have positive mean and the other negative.

• Isn't this a convoluted way to $A = \alpha B$ where $\alpha$ is some scalar? Feb 10, 2017 at 21:05
• @MatthewGunn Your comment is right on target. Normality has nothing to do with the matter. For random variables $A$ and $B$ such that $A = \alpha B$, $E[A\mid B] = \alpha B = A$ and similarly, $E[B\mid A] = B$. Consequently, assuming that $E[B]\neq 0$, $$E[A\mid B] = \alpha B = E[B\mid A]\cdot\alpha = E[B\mid A]\frac{\alpha E[B]}{E[B]} = E[B\mid A]\frac{E[A]}{E[B]}.$$ No normality, no $|cv_A|=|cv_B|$ etc, and actually just a rehash of a comment in Michael Hardy's answer. Feb 11, 2017 at 2:37
• If you write \text{Var} instaed of \operatorname{Var} then you'll see $a\text{Var}X$ and $a\text{Var}(X)$ instead of $a\operatorname{Var}X$ and $a\operatorname{Var}(X).$ That's why the latter is standard usage. Feb 11, 2017 at 17:10
• @MatthewGun It seems to me that providing answers that contain specific examples is considered valuable content in this site. So yes, when a random variable is an affine function of another, and they are jointly normal with non-zero means, then one needs to have equal coefficients of variation, while, also there are no restrictions on the means of these rv's. On the other hand, when a random variable is just a linear function of another, the relation holds always. So no my answer is not a convoluted way to say $A=aB$. (cc:@DilipSarwate) Feb 11, 2017 at 18:39
• If $B$ is a non-normal random variable with $E[B]=\mu_B\neq 0$ and $A=c B+d$ (and so $B=\frac{A-d}{c}$), then $$E[A\mid B]=cB+d=A, E[B\mid A]=\frac{A-d}{c}=B.$$ Now, if we want to have $E[A\mid B]=cB+d$ to equal $E[B\mid A]\cdot\frac{\mu_A}{\mu_B} =B\cdot\frac{\mu_A}{\mu_B}$, it must be that $$cB+d=B\cdot\frac{\mu_A}{\mu_B}\implies d=0,c=\frac{\mu_A}{\mu_B}$$ and so $A=cB=\frac{\mu_A}{\mu_B}B$. So, for nonnormal $B$, the OP's conjectured result holds if $A=cB$ but not if $A=cB+d, d\neq 0$.Of course, as you have proved, the result holds for normal random variables if $A=cB+d, d\neq 0$ . Feb 14, 2017 at 3:57