 The sum_x P(X, y, Z) in the denominator of the second equality should be sum_x P(x, y, Z)
The sum_x P(X, y, Z) in the denominator of the second equality should be sum_x P(x, y, Z)