Skip to content

refactor: Hypothesis Testing#20

Merged
huangziwei merged 18 commits into
mainfrom
hypothesis
Jun 8, 2026
Merged

refactor: Hypothesis Testing#20
huangziwei merged 18 commits into
mainfrom
hypothesis

Conversation

@huangziwei

@huangziwei huangziwei commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

The main changes this round of refactoring is to bring randomization test (for p-values) to more hypothesis tests.

New

Resampling-based p-values aka randomization test

previously only rayleigh_test has a resampling p-value, we now roll it out to most of the hypothesis testing (some still lack it because it doesn't make a lot of sense).

rayleigh_test(alpha)                      # analytic, method="asymptotic"
rayleigh_test(alpha, n_resamples=9999)    # method="monte_carlo"
concentration_test([a, b], n_resamples=9999, seed=1)   # method="randomization"
watson_test(a, dist="vonmises", n_resamples=999)       # method="parametric_bootstrap"

Check docstring for usage. But in short:

  • most hypothesis tests use n_resmpling=0 for analytical p-value and n_resampling>0 for simulation-based one.
  • but for symmetry_test(method="wilcoxon"|"pewsey") , where wilcoxon has no simulation based p-value, only pewsey has; watson_test(method="uniform"|"vonmises"), where uniformonly work for both n_resamples=0 or >0, butvonmisesonly works forn_resamples>0`.

new hypothesis tests

  • kuiper_two_test, which matches CircStat and pycircstat's two sample kuiper and circ_kuipertest . The original kuiper_test matches R's CircStats and circular's kuiper and kuiper.test
  • watson_test(dist="vonmises") matches circular's watson.test(dist="vonmises")

Bug fixes

  • omnibus_test: denim can be <=0 as m approached n/2, and we wrongly reported the pval=0 which should be 1.
  • watson_u2_test: cumfreq assumed input data are sorted but we didn't
  • wheeler_watson_test: didn't consider ties
  • wallraff_test: didn't work for grouped data

all fixed.

Others

typos, style, lints, api harmonization, etc. most changes should be backward compatible.

@huangziwei huangziwei changed the title [WIP] refactor: Hypothesis refactor: Hypothesis Jun 8, 2026
@huangziwei huangziwei changed the title refactor: Hypothesis refactor: Hypothesis Testing Jun 8, 2026
@huangziwei huangziwei merged commit 1336bf6 into main Jun 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant