def reduced_chi_squared(yfit, y, sigma, degrees):
    """Given yfit, y, sigma, and (the number of) degrees of freedom,
    return the reduced chi-squared value.
    """
    error = yfit - y
    return sum(error*error/sigma/sigma) / degrees