示例#1
0
def test_binomial_approx_sample(total_count, prob):
    sample_shape = (10000, )
    d = dist.Binomial(total_count, prob)
    expected = d.sample(sample_shape)
    with set_approx_sample_thresh(200):
        actual = d.sample(sample_shape)

    assert_close(expected.mean(), actual.mean(), rtol=0.05)
    assert_close(expected.std(), actual.std(), rtol=0.05)
示例#2
0
def test_beta_binomial_approx_sample(concentration1, concentration0,
                                     total_count):
    sample_shape = (10000, )
    d = dist.BetaBinomial(concentration1, concentration0, total_count)
    expected = d.sample(sample_shape)
    with set_approx_sample_thresh(200):
        actual = d.sample(sample_shape)

    assert_close(expected.mean(), actual.mean(), rtol=0.1)
    assert_close(expected.std(), actual.std(), rtol=0.1)