def test_log_prob_normalized(concentration): grid = torch.arange(0., 2 * math.pi, 1e-4) prob = VonMises(0.0, concentration).log_prob(grid).exp() norm = prob.mean().item() * 2 * math.pi assert abs(norm - 1) < 1e-3, norm
def test_log_prob_normalized(concentration): grid = torch.arange(0, 2 * math.pi, 1e-4) prob = VonMises(0.0, concentration).log_prob(grid).exp() norm = prob.mean().item() * 2 * math.pi assert abs(norm - 1) < 1e-3, norm
def test_sample(loc, concentration, n_samples=int(1e6), n_iter=50): prob = VonMises(loc, concentration) samples = prob.sample((n_samples, )) mu, kappa = _fit_params_from_samples(samples, n_iter=n_iter) assert abs(loc - mu) < 0.1 assert abs(concentration - kappa) < concentration * 0.1
def test_von_mises_gof(loc, concentration): d = VonMises(loc, concentration) samples = d.sample(torch.Size([100000])) probs = d.log_prob(samples).exp() gof = auto_goodness_of_fit(samples, probs, dim=1) assert gof > TEST_FAILURE_RATE