Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 186 additions & 81 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/pted/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .pted import pted, pted_coverage_test
from .pted import pted, pted_coverage_test, pted_containment_test
from .tests import test
from .utils import hdp_coverage_test
from ._version import version as __version__ # noqa
Expand All @@ -9,6 +9,7 @@
__all__ = [
"pted",
"pted_coverage_test",
"pted_containment_test",
"hdp_coverage_test",
"test",
"__version__",
Expand Down
383 changes: 293 additions & 90 deletions src/pted/pted.py

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/pted/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ def test():
np.random.seed(42)
# example 2 sample test
D = 300
for _ in range(20):
x = np.random.normal(size=(100, D))
y = np.random.normal(size=(100, D))
p = pted(x, y)
assert p > 1e-2 and p < 0.99, f"p-value {p} is not in the expected range (U(0,1))"
# Under the null these are U(0,1), so any single draw can land anywhere:
# check the batch, not each p-value. Asserting 0.01 < p < 0.99 on each of
# 20 uniform draws fails a third of the time on its own.
pvals = [
pted(np.random.normal(size=(100, D)), np.random.normal(size=(100, D))) for _ in range(20)
]
median = float(np.median(pvals))
assert 0.1 < median < 0.9, f"null p-values are not U(0,1): median {median}, {pvals}"

x = np.random.normal(size=(100, D))
y = np.random.uniform(size=(100, D))
Expand Down
Loading
Loading