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
42 changes: 0 additions & 42 deletions src/resample/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from scipy.stats import tiecorrect as _tiecorrect

from ._util import _normalize_rng
from .empirical import cdf_gen

_dataclass_kwargs = {"frozen": True, "repr": False}
if sys.version_info >= (3, 10):
Expand Down Expand Up @@ -434,29 +433,6 @@ def kruskal(
return same_population(_kruskal, x, y, *args, **kwargs)


def ks(x: _ArrayLike, y: _ArrayLike, **kwargs: _Kwargs) -> TestResult:
"""
Test whether two samples are drawn from the same population using the KS distance.

This performs the permutation-based two-sided Kolmogorov-Smirnov test.

Parameters
----------
x : array-like
First sample.
y : array-like
Second sample.
**kwargs :
Keyword arguments are forward to :meth:`same_population`.

Returns
-------
TestResult
"""
kwargs["transform"] = None
return same_population(_KS(), x, y, **kwargs)


def pearsonr(x: _ArrayLike, y: _ArrayLike, **kwargs: _Kwargs) -> TestResult:
"""
Test whether two samples are drawn from the same population using the correlation.
Expand Down Expand Up @@ -622,24 +598,6 @@ def _init(self, args: _tp.Tuple[np.ndarray, ...]) -> None:
self.a_bar = np.mean(np.concatenate(args))


class _KS:
all = None

def __call__(self, *args: np.ndarray) -> float:
if self.all is None:
self._init(args)
x, y = args
f1 = cdf_gen(x)
f2 = cdf_gen(y)
d = f1(self.all) - f2(self.all)
d1 = np.clip(-np.min(d), 0, 1)
d2 = np.max(d)
return max(d1, d2)

def _init(self, args: _tp.Tuple[np.ndarray, ...]) -> None:
self.all = np.concatenate(args)


def _wilson_score_interval(n1, n, z):
p = n1 / n
norm = 1 / (1 + z**2 / n)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __getitem__(self, key):
scipy = Scipy(
anova=stats.f_oneway,
mannwhitneyu=lambda x, y: stats.mannwhitneyu(x, y, alternative="two-sided"),
ks=stats.ks_2samp,
ttest=lambda x, y: stats.ttest_ind(x, y, equal_var=False),
)

Expand All @@ -74,7 +73,6 @@ def __getitem__(self, key):
"anova",
"mannwhitneyu",
"kruskal",
"ks",
"pearsonr",
"spearmanr",
"ttest",
Expand All @@ -101,7 +99,6 @@ def test_two_sample_same_size(test_name, size, rng):
"anova",
"mannwhitneyu",
"kruskal",
"ks",
"pearsonr",
"spearmanr",
"ttest",
Expand Down