def alpha(y, x, err=None, return_kappa=False, cov=False):
    '\n    this returns -1*alpha, and optionally kappa and errors\n    '
    a1 = set(np.nonzero(np.multiply(x, y))[0])
    a2 = set(np.where(np.isfinite(np.add(x, y, err)))[0])
    a = np.asarray(list((a1 & a2)))
    y = np.log(y[a])
    x = np.log(x[a])
    if (err is None):
        (p, covar) = np.polyfit(x, y, 1, cov=True)
        (m, b) = p
        (me, be) = np.sqrt(np.sum((covar * [[1, 0], [0, 1]]), axis=1))
        (me, be)
    else:
        err = err[a]
        err = (err / y)
        (p, covar) = np.polyfit(x, y, 1, w=(1.0 / (err ** 2)), cov=True)
        (m, b) = p
        (me, be) = np.sqrt(np.sum((covar * [[1, 0], [0, 1]]), axis=1))
        (me, be)
    if return_kappa:
        if cov:
            return (m, np.exp(b), me, be)
        else:
            return (m, np.exp(b))
    elif cov:
        return (m, me)
    else:
        return m
this returns -1*alpha, and optionally kappa and errors
def alpha(y, x, err=None, return_kappa=False, cov=False):
    '\n    \n    '
    a1 = set(np.nonzero(np.multiply(x, y))[0])
    a2 = set(np.where(np.isfinite(np.add(x, y, err)))[0])
    a = np.asarray(list((a1 & a2)))
    y = np.log(y[a])
    x = np.log(x[a])
    if (err is None):
        (p, covar) = np.polyfit(x, y, 1, cov=True)
        (m, b) = p
        (me, be) = np.sqrt(np.sum((covar * [[1, 0], [0, 1]]), axis=1))
        (me, be)
    else:
        err = err[a]
        err = (err / y)
        (p, covar) = np.polyfit(x, y, 1, w=(1.0 / (err ** 2)), cov=True)
        (m, b) = p
        (me, be) = np.sqrt(np.sum((covar * [[1, 0], [0, 1]]), axis=1))
        (me, be)
    if return_kappa:
        if cov:
            return (m, np.exp(b), me, be)
        else:
            return (m, np.exp(b))
    elif cov:
        return (m, me)
    else:
        return m