def integrand(x): log_p = base_dist.logpdf(x, df=k) log_q = powerlaw.logpdf(x, a=k, loc=a, scale=L) delta = log_p - log_q v = mult0(np.exp(log_p), log_logistic(delta)) + \ mult0(np.exp(log_q), log_logistic(-delta)) return v
def mix_logpdf(x, k, a, L): lp1 = base_dist.logpdf(x, df=k) lp2 = powerlaw.logpdf(x, a=k, loc=a, scale=L) logpdf = logsumexp([lp1, lp2]) + np.log(0.5) return logpdf
def mix_logpdf(x, k, a, L): lp1 = base_dist.logpdf(x, df=k) lp2 = powerlaw.logpdf(x, a=k, loc=a, scale=L) logpdf = logsumexp([lp1, lp2]) + np.log(0.5) #logpdf_chk = np.log(0.5 * np.exp(lp1) + 0.5 * np.exp(lp2)) #print logpdf, logpdf_chk #assert(np.allclose(logpdf, logpdf_chk)) return logpdf
def integrand_2(x): log_p = base_dist.logpdf(x, df=k) log_q = powerlaw.logpdf(x, a=k, loc=a, scale=L) delta = log_p - log_q v = np.exp(log_q) * log_logistic(-delta) return v
def integrand(x): pp = powerlaw.pdf(x, a=k, loc=a, scale=L) v = pp * (powerlaw.logpdf(x, a=k, loc=a, scale=L) - mix_logpdf(x, k, a, L)) return v