def plot_pred_lls(results):
    # Plot predictive log likelihoods
    homog_rates = np.zeros(K)
    for k in range(K):
        homog_rates[k] = (C_train==k).sum() / T_train

    homog_pll = 0
    for k in range(K):
        homog_pll += -T_test * homog_rates[k]
        homog_pll += (C_test==k).sum() * np.log(homog_rates[k])

    # Plot predictive log likelihoods relative to standard Poisson
    plt.figure()
    for i,result in enumerate(results):
        lls, plls, Weffs, Ps, Ls = result
        plls = plls[N_samples//2:]
        J = len(plls)
        avg_pll = -np.log(J) + logsumexp(plls)
        avg_pll = (avg_pll - homog_pll) / len(S_test)

        samples = np.random.choice(plls, size=(100, J), replace=True)
        pll_samples = logsumexp((homog_pll - samples)/len(S_test), axis=1) - np.log(J)
        std_hll = pll_samples.std()

        print "PLL: ", avg_pll, " +- ", std_hll
        plt.bar(i, avg_pll)
    plt.show()
dataset/ETHPy150Open slinderman/pyhawkes/experiments/hippocampus.py/plot_pred_lls/swapped operands of `-`