def lifetime_accum(lifetime, X_s, X_t):
    """
    Compute the lifetime by integrating the correlation function
    and accumulate the result into the given lifetime object.

    Parameters
    ----------
    X_s: array-like
        Array with the correlation function.
        Works also with other decaying scores that are defined
        in the range [0,1]=[min_skill,max_skill].
    X_t: array-like
        Array with the forecast lead times in the desired unit,
        e.g. [min, hour].
    """
    if lifetime["rule"] == "trapz":
        lf = np.trapz(X_s, x=X_t)
    elif lifetime["rule"] == "simpson":
        lf = simpson(X_s, x=X_t)
    elif lifetime["rule"] == "1/e":
        euler_number = 1.0 / exp(1.0)
        X_s_ = np.array(X_s)

        is_euler_reached = np.sum(X_s_ <= euler_number) > 0
        if is_euler_reached:
            idx_b = np.argmax(X_s_ <= euler_number)
            if idx_b > 0:
                idx_a = idx_b - 1
                fraction_score = (
                    (euler_number - X_s[idx_b])
                    * (X_t[idx_a] - X_t[idx_b])
                    / (X_s[idx_a] - X_s[idx_b])
                )
                lf = X_t[idx_b] + fraction_score
            else:
                # if all values are below the 1/e value, return min lead time
                lf = np.min(X_t)
        else:
            # if all values are above the 1/e value, return max lead time
            lf = np.max(X_t)

    lifetime["lifetime_sum"] += lf
    lifetime["n"] += 1
Compute the lifetime by integrating the correlation function
and accumulate the result into the given lifetime object.

Parameters
----------
X_s: array-like
Array with the correlation function.
Works also with other decaying scores that are defined
in the range [0,1]=[min_skill,max_skill].
X_t: array-like
Array with the forecast lead times in the desired unit,
e.g. [min, hour].
pysteps/verification/lifetime.py