def compute_generalized_logw(log_gamma_old, log_gamma_new, log_forward_kernelt, log_backward_kernel_tm1):
    """
    compute a generalized log incremental (unnormalized) weight

    arguments
        log_gamma_old : float
            log unnormalized probability distribution at t-1 (and position x_{t-1})
        log_gamma_new : float
            log unnormalized probability distribution at t (and positions x_t)
        log_forward_kernelt : float
            log of forward transition kernel probability
        log_backward_kernel_tm1 : float
            log of backward transition kernel probability

    returns
        logw : float
            log incremental weight of path importance
    """
    logw = log_gamma_new + log_backward_kernel_tm1 - log_gamma_old - log_forward_kernelt
    return logw