Skip to content

Commit

Permalink
Create test_rpkb_approximation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rmj3197 committed Sep 13, 2024
1 parent cb657af commit e22fc4d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_rpkb_approximation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Tests the rpkb random sampling with wrapped cauchy.
"""

import numpy as np
from scipy.stats import wrapcauchy

from QuadratiK.spherical_clustering import PKBD


class TestApproximation:
def test(self):
n = 10000
loc = np.array([-1, 0])
rho = 0.6

wrapped_cauchy = wrapcauchy.rvs(rho, loc=-np.pi, size=n)
pkbd = PKBD().rpkb(n=10000, mu=loc, rho=rho)
pkbd_angles = np.arctan2(pkbd[:, 1], pkbd[:, 0])

quantiles = np.arange(0.05, 1, 0.05)

wc_q = np.quantile(wrapped_cauchy, quantiles)
pkbd_q = np.quantile(pkbd_angles, quantiles)

np.testing.assert_allclose(wc_q, pkbd_q, atol=0.1)

0 comments on commit e22fc4d

Please sign in to comment.