<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def z_cost(z, errors, mean, std):
 """Compute how bad a z value is. The original formula is:: (delta_mean/mean) + (delta_std/std) number of errors above + (number of sequences above)^2 which computes the "goodness" of `z`, meaning that the higher the value the better the `z`. In this case, we return this value inverted (we make it negative), to convert it into a cost function, as later on we will use scipy to minimize it. """


    epsilon = mean + z * std

    delta_mean, delta_std = deltas(errors, epsilon, mean, std)
    above, consecutive = count_above(errors, epsilon)

    numerator = -(delta_mean / mean + delta_std / std)
    denominator = above + consecutive ** 2

    if denominator == 0:
        return np.inf

    return numerator / denominator