<s>[INST] Discrete Random variable, finding pmf of X Q: A fair coin is tossed independently 5 times. Let X denote the difference between the number of heads and the number of tails obtained. find the probability mass function of X
here's my take:
P(X=0) = all heads or all tails = 1/32 + 1/32 = 2/32 
P(X=4) = one head or one tail = 5C1 x 1/32 + 5C1 x 1/32 = 10/32
P(X=3) = two heads or two tails = (5C2 x 1/32)^2 = 20/32
P(X=2) = three heads or three tails = (5C3 x 1/32)^2= 20/32
P(X=1) = four heads or four tails =  (5C4 x 1/32)^2 x 1/2 = 10/32
but i dont think i am on the right track. did i understand question completely wrong? i know pmf should equal 1 and my answer exceeds that. so i know im wrong for sure
 [/INST] Not quite. Convince yourself that
$$P(X = 0) = P(X=2) =P(X = 4) = 0.$$
Then for the difference to be 1, then either you got 3 heads in 5 flips, or 3 tails in 5 flips. Thus,
$$P(X = 1) = \binom{5}{3} \left(\frac{1}{2}\right)^3 \left(\frac{1}{2}\right)^2
+\binom{5}{3} \left(\frac{1}{2}\right)^3 \left(\frac{1}{2}\right)^2 = 2\binom{5}{3} \left(\frac{1}{2}\right)^3 \left(\frac{1}{2}\right)^2$$
Similarly,
$$P(X=3) = 2\binom{5}{4} \left(\frac{1}{2}\right)^4 \left(\frac{1}{2}\right)^1,$$
and
$$P(X=5)= 2\binom{5}{5} \left(\frac{1}{2}\right)^5 \left(\frac{1}{2}\right)^0.$$
You can verify that indeed the sum of these cases adds to 1.
</s>