# Geometric and binomial

Let X be a random variable with X Geom(1/3). Let Y be another random variable
with Y Bin(n, 1/4) where n is the value taken by the random variable X.

1. Using the law of total probability, or otherwise, compute the expectation of Y. I got 3n/8

2. Using the law of total probability, or otherwise, compute the expectation of the product XY and hence compute the covariance of the random variables X and Y .
I got E(XY)= 9n/8 and Cov(x,y)=0
Original post by hellohello05
Let X be a random variable with X Geom(1/3). Let Y be another random variable
with Y Bin(n, 1/4) where n is the value taken by the random variable X.
1. Using the law of total probability, or otherwise, compute the expectation of Y. I got 3n/8
2. Using the law of total probability, or otherwise, compute the expectation of the product XY and hence compute the covariance of the random variables X and Y .
I got E(XY)= 9n/8 and Cov(x,y)=0

Can you upload what you did? Not worked it through fully, but cant see why it would depend on n. To get some insight, you could write the joint probabilities as a table with X (n) across the top and Y (m) down the side and the table entries are the joints. Then margnialise (total probability, sum over X or n) to get p(Y=m) and compute the expectation from that.
(edited 2 months ago)
Hmm... Here are some sanity checks.

1, You should be able to explicitly calculate what E[Y] is, that's independent of n. Similarly with E[XY].
2, Covariance zero means X and Y are independent, which is definitely not the case here. My guess is at some point you claimed E[XY] = E[X]E[Y] - that's not generally true.

It would be helpful if you post your working. I have a suspicion you've got the setup wrong...
(edited 2 months ago)
Original post by mqb2766
Can you upload what you did? Not worked it through fully, but cant see why it would depend on n. To get some insight, you could write the joint probabilities as a table with X (n) across the top and Y (m) down the side and the table entries are the joints. Then margnialise (total probability, sum over X or n) to get p(Y=m) and compute the expectation from that.

Please find my working out attached
Original post by tonyiptony
Hmm... Here are some sanity checks.
1, You should be able to explicitly calculate what E[Y] is, that's independent of n. Similarly with E[XY].
2, Covariance zero means X and Y are independent, which is definitely not the case here. My guess is at some point you claimed E[XY] = E[X]E[Y] - that's not generally true.
It would be helpful if you post your working. I have a suspicion you've got the setup wrong...

Oh right, how would I work out E(XY) in that case?
Original post by hellohello05

For the first part, n/8 is not a constant "first term" as it depends on the series index so its not a geometric series, its an
https://en.wikipedia.org/wiki/Arithmetico-geometric_sequence
which its easy enough to derive the basic sum formula by shift and difference to get a geometric ... to get the staircase sum formula.

Its roughly the discrete case of using integration by parts to integrate xe^(-x) rather than just e^(-x), where the latter is an exponential/geometric.
(edited 2 months ago)
Original post by mqb2766
For the first part, n/8 is not a constant "first term" as it depends on the series index so its not a geometric series, its an
https://en.wikipedia.org/wiki/Arithmetico-geometric_sequence
which its easy enough to derive the basic sum formula by shift and difference to get a geometric ... .
Its roughly the discrete case of using integration by parts to integrate xe^(-x) rather than just e^(-x), where the latter is an exponential/geometric.

oh so would it just be 3/8
Original post by hellohello05
oh so would it just be 3/8

Have you worked that out, if so how, or just crossed off the n?
The trick to deal with sums like $\sum_{n} n(2/3)^{n}$ is to notice that it almost looks like a geometric series, but differentiated. i.e. instead of $\sum_{n} x^{n}$ evaluated at x=2/3, we almost have $\sum_{n} nx^{n-1}$ evaluated at x=2/3. See if this observation takes you anywhere.

That said, I wonder if you've learned something called Tower Property for calculating expectation. It's effectively law of total probability, but the expectation version. Using Tower Property completely avoids calculating the sum.

For E[XY], my way is to just calculate from definition, so we want $\sum_{x}\sum_{y} xyP(X=x,Y=y) = \sum_{x}\sum_{y} xyP(Y=y | X=x)P(X=x)=...$ (it actually turns out quite nice if you move the correct terms out of the inner summation). But then I have no idea where law of total probability comes in, so that's probably "the dumb route".

---

As a little extension to what I said in #2, if E[XY] = E[X]E[Y] always holds, then for any distribution, var(X) = E[X^2] - (E[X])^2 = 0, which makes no sense. Remember this absurdity. Basically expectation is linear, i.e. you can pull the plus sign out and the scalar multiple out, but nothing else.
(edited 2 months ago)