import math


def compute_mean_ic(pwm):
    """Compute mean information content of a PWM."""
    ic = 0.0
    for column in range(pwm.length):
        for base in pwm.alphabet:
            ic += pwm[base][column] * math.log2(pwm[base][column]/pwm.background[base])
    ic /= float(pwm.length)
    return ic