Пример #1
0
def test_von_mises_3d_gof(scale):
    concentration = torch.randn(3)
    concentration = concentration * (scale / concentration.norm(2))
    d = VonMises3D(concentration, validate_args=True)

    with xfail_if_not_implemented():
        samples = d.sample(torch.Size([2000]))
    probs = d.log_prob(samples).exp()

    gof = auto_goodness_of_fit(samples, probs, dim=2)
    assert gof > TEST_FAILURE_RATE
Пример #2
0
def test_von_mises_3d(scale):
    concentration = torch.randn(3)
    concentration = concentration * (scale / concentration.norm(2))

    num_samples = 100000
    samples = torch.randn(num_samples, 3)
    samples = samples / samples.norm(2, dim=-1, keepdim=True)

    d = VonMises3D(concentration, validate_args=True)
    actual_total = d.log_prob(samples).exp().mean()
    expected_total = 1 / (4 * math.pi)
    ratio = actual_total / expected_total
    assert torch.abs(ratio - 1) < 0.01, ratio