def lifetime(X_s, X_t, rule="1/e"):
    """
    Compute the average lifetime by integrating the correlation function
    as a function of lead time. When not using the 1/e rule, the correlation
    function must be long enough to converge to 0, otherwise the lifetime is
    underestimated. The correlation function can be either empirical or
    theoretical, e.g. derived using the function 'ar_acf'
    in timeseries/autoregression.py.

    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].
    rule: str {'1/e', 'trapz', 'simpson'}, optional
        Name of the method to integrate the correlation curve. \n
        '1/e' uses the 1/e rule and assumes an exponential decay. It linearly
        interpolates the time when the correlation goes below the value 1/e.
        When all values are > 1/e it returns the max lead time.
        When all values are < 1/e it returns the min lead time. \n
        'trapz' uses the trapezoidal rule for integration.\n
        'simpson' uses the Simpson's rule for integration.

    Returns
    -------
    lf: float
        Estimated lifetime with same units of X_t.
    """
    X_s = X_s.copy()
    X_t = X_t.copy()
    life = lifetime_init(rule)
    lifetime_accum(life, X_s, X_t)
    return lifetime_compute(life)
Compute the average lifetime by integrating the correlation function
as a function of lead time. When not using the 1/e rule, the correlation
function must be long enough to converge to 0, otherwise the lifetime is
underestimated. The correlation function can be either empirical or
theoretical, e.g. derived using the function 'ar_acf'
in timeseries/autoregression.py.

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].
rule: str {'1/e', 'trapz', 'simpson'}, optional
Name of the method to integrate the correlation curve. \n
'1/e' uses the 1/e rule and assumes an exponential decay. It linearly
interpolates the time when the correlation goes below the value 1/e.
When all values are > 1/e it returns the max lead time.
When all values are < 1/e it returns the min lead time. \n
'trapz' uses the trapezoidal rule for integration.\n
'simpson' uses the Simpson's rule for integration.

Returns
-------
lf: float
Estimated lifetime with same units of X_t.
pysteps/verification/lifetime.py