def _test(shape, n): rv = InvGamma(shape, alpha=tf.zeros(shape)+0.5, beta=tf.zeros(shape)+0.5) rv_sample = rv.sample(n) x = rv_sample.eval() x_tf = tf.constant(x, dtype=tf.float32) alpha = rv.alpha.eval() beta = rv.beta.eval() for idx in range(shape[0]): assert np.allclose( rv.log_prob_idx((idx, ), x_tf).eval(), stats.invgamma.logpdf(x[:, idx], alpha[idx], scale=beta[idx]))
def _test(shape, n): rv = InvGamma(shape, alpha=tf.zeros(shape)+0.5, beta=tf.zeros(shape)+0.5) rv_sample = rv.sample(n) with sess.as_default(): x = rv_sample.eval() x_tf = tf.constant(x, dtype=tf.float32) alpha = rv.alpha.eval() beta = rv.beta.eval() for idx in range(shape[0]): assert np.allclose( rv.log_prob_idx((idx, ), x_tf).eval(), stats.invgamma.logpdf(x[:, idx], alpha[idx], scale=beta[idx]))