# Is Mathematica computing the conditional expectation correctly?

Given a simple case of say 2 independent trials each with probability of success 1/3. Consider a random variable that is gives the 3 times the total successes.

We can define this random variable in terms of predefined distributions by simply setting it as 3 x BinomialDistribution[2,1/3].

I want to calculate the expected value of this variable given atleast one success which I try to calculate as follows:

Expectation[x\[Conditioned](x>0),x\[Distributed]TransformedDistribution[3x,x\[Distributed]BinomialDistribution[2,1/3.]]]


But this gives a weird answer

10.6592

Even if i remove the zeros of this distribution its mean cannot be larger than the max value of the variable which is 6 in this case.

The answer I expect can be achieved using:

Expectation[3x\[Conditioned](3x>0),x\[Distributed]BinomialDistribution[2,1/3.]]


So the TransformedDistribution is bugging right?

{
PDF[TransformedDistribution[3x,x\[Distributed]BinomialDistribution[2,1/3.]],x],
PDF[BinomialDistribution[2,1./3],x/3]
}//FullSimplify


Both are producing the same crazy PDF, there are no Boole[...] to set non-integer values to zero.

• Yeah I think it is bugging indeed, perhaps you can use: Expectation[3 x [Conditioned] (x > 0), x [Distributed] BinomialDistribution[2, 1/3.]] – SHuisman Sep 14 at 19:58
• @JimB - it sums to 1 for what should be the support, but sums to >1 over the range. – ciao Sep 15 at 3:35
• @ciao You are correct. But if I can offer a feeble defense: Sum[PDF[d, z], {z, 0, n}] sums to 1 for any finite value for n. It only chokes when one plugs in $\infty$. – JimB Sep 15 at 3:41
• @JimB - it gets weirder. zz = PDF[dist, x]; {Sum[zz, {x, 0, 6}] // N, Sum[PDF[dist, x], {x, 0, 6}] // N} returns {2.58266,1.}. – ciao Sep 15 at 3:48
• @ciao. Wow! It does indeed get weirder! Sum[zz, {x, 0, 6, 3}] gives 1 but Sum[zz, {x, 0, 6, 1}] gives 2.58266. Also, zz := PDF[dist, x]; Sum[zz, {x, 0, 6}] // N gives 1. – JimB Sep 15 at 4:03