Solution (source code)

= Solution

For finite-valued <random vectors>, the <conditional entropy> is the average of the entropies of the conditional distributions:
$$
\boxed{H(X\mid Y)=\sum_{y:p_Y(y)>0}p_Y(y)\left[-\sum_xp(x\mid y)\log_2p(x\mid y)\right]}.
$$
Use $0\log_2 0=0$ and omit zero-<probability> conditioning events. Equivalently,
$$
H(X\mid Y)=-\sum_{x,y:p(x,y)>0}p(x,y)\log_2\frac{p(x,y)}{p_Y(y)}.
$$
The base two makes all information quantities measured in <bits>; changing the logarithm base scales them by a positive constant and preserves the inequalities.