def ChiSqStat(ydata, yerr, ymodel):
    """
    Returns the chi-square given arrays of ydata, yerr, and ymodel values.
    """
    chisquared = ((ydata - ymodel)/yerr)**2 
    stat = chisquared.sum()
    return stat