When you compute H(A,B), you sum the terms P(a)P(b)logP(a,b). I think you should be summing P(a,b)logP(a,b) instead.
When you compute H(A,B), you sum the terms P(a)P(b)logP(a,b). I think you should be summing P(a,b)logP(a,b) instead.