コード例 #1
0
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]))
コード例 #2
0
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]))
コード例 #3
0
def _test(shape, a, scale, n):
    x = InvGamma(shape, a, scale)
    val_est = tuple(get_dims(x.sample(n)))
    val_true = (n, ) + shape
    assert val_est == val_true
コード例 #4
0
def _test(shape, a, scale, size):
    x = InvGamma(shape, a, scale)
    val_est = tuple(get_dims(x.sample(size=size)))
    val_true = (size, ) + shape
    assert val_est == val_true
コード例 #5
0
def _test(shape, a, scale, n):
    x = InvGamma(shape, a, scale)
    val_est = tuple(get_dims(x.sample(n)))
    val_true = (n, ) + shape
    assert val_est == val_true