def convert_nbinom_params(mu, var):
    """
    Converts mean and variance into the n and p parameters used by scipy.stats
    """
    if not var > mu:
        raise ValueError(
            'Variance must be greater than mean for negative binomial distribution'
            )
    p = mu / float(var)
    n = mu * p / float(1 - p)
    return n, p
