So I'm practicing working with Bayes Networks and conditional probability tables and I feel like some of my numbers simply don't make sense.
Here's the situation: I have a bag of three different biased coins. Coin A has P(heads) of 0.2, coin B has P(heads) of 0.6, and coin C has P(heads) of 0.8.
I pick a coin at random and then flip it three times. I'm trying to work out the probability of each coin being the chosen coin, given a result of two heads and a tails.
So, based on this, I drew up a Bayesian network with the following CPTs:
Coin chosen C: P(C):
a .33
b .33
c .33
and
coin flip F: P(F|C=a): P(F|C=b): P(F|C=c):
heads 0.2 0.6 0.8
tails 0.8 0.4 0.2
From Bayes' Rule, I know that
P(C|f1,f2,f3) = P(C,f1,f2,f3) / P(f1,f2,f3)
,
and that P(C,f1,f2,f3) = P(C)*P(f1|C)*P(f2|C)*P(f3|C)
because the three flips are dependent upon C, but independent of one another. Also, I know that P(f1,f2,f3) = sum(P(C,f1,f2,f3)) over all values of C
Plugging in the numbers, I get the following:
P(C=a,f1=h,f2=h,f3=t) = P(C=a)*P(f1=h|C=a)*P(f2=h|C=a)*P(f3=t|C=a) = .33*.2*.2*.8 = .01056
P(C=b,f1=h,f2=h,f3=t) = P(C=b)*P(f1=h|C=b)*P(f2=h|C=b)*P(f3=t|C=b) = .33*.6*.6*.4 = .04752
P(C=c,f1=h,f2=h,f3=t) = P(C=c)*P(f1=h|C=c)*P(f2=h|C=c)*P(f3=t|C=c) = .33*.8*.8*.2 = .04224
P(f1=h,f2=h,f3=t) = P(f1=h,f2=h,f3=t|C=a) + P(f1=h,f2=h,f3=t|C=b) + P(f1=h,f2=h,f3=t|C=c) = (.2*.2*.8)+(.6*.6*.4)+(.8*.8*.2) = 0.304
With those values, I compute P(C|h,h,t)
:
P(C=a|h,h,t) = P(C=a,h,h,t) / P(h,h,t) = 0.01056/0.304 = 0.0347
P(C=b|h,h,t) = P(C=b,h,h,t) / P(h,h,t) = 0.04752/0.304 = 0.1558
P(C=c|h,h,t) = P(C=c,h,h,t) / P(h,h,t) = 0.04224/0.304 = 0.1384
I don't think these numbers make sense, however. Shouldn't the sum of P(C|h,h,t)
for all values of C be equal to 1? I think I may have done something wrong in my calculation of P(h,h,t)
above, as a value of 0.304
would imply that 90% of the time I would end up with two heads and a tails (as P(h,h,t)
would be equal to P(h,t,h)
and P(t,h,h)
)