ESS (Effective sample size) computed from log-weights.

    Parameters
    ----------
    lw: (N,) ndarray
        log-weights 

    Returns
    -------
    float 
        the ESS of weights w = exp(lw), i.e. the quantity  
        sum(w**2) / (sum(w))**2

    Note 
    ----
    The ESS is a popular criterion to determine how *uneven* are the weights. 
    Its value is in the range [1, N], it equals N when weights are constant,
    and 1 if all weights but one are zero.

def essl(lw):
    """ESS (Effective sample size) computed from log-weights.

    Parameters
    ----------
    lw: (N,) ndarray
        log-weights 

    Returns
    -------
    float 
        the ESS of weights w = exp(lw), i.e. the quantity  
        sum(w**2) / (sum(w))**2

    Note 
    ----
    The ESS is a popular criterion to determine how *uneven* are the weights. 
    Its value is in the range [1, N], it equals N when weights are constant,
    and 1 if all weights but one are zero. 

    """
    w = np.exp(lw - lw.max())
    return (w.sum())**2 / np.sum(w**2)