Skip to content

Commit 2ff8f48

Browse files
authored
Merge pull request #148 from statlab/doc-fix
DOC: fix documentation of calling signature for test statistic in core
2 parents 8253ada + cc51b86 commit 2ff8f48

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

permute/core.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,15 @@ def two_sample(x, y, reps=10**5, stat='mean', alternative="greater",
196196
approximating the permutation distribution.
197197
The t-statistic is computed using scipy.stats.ttest_ind
198198
(c) If stat is a function (a callable object), the test statistic is
199-
that function. The function should take two arguments:
199+
that function. The function should take two arguments:
200200
given a permutation of the pooled data, the first argument is the
201201
"new" x and the second argument is the "new" y.
202202
For instance, if the test statistic is the Kolmogorov-Smirnov distance
203203
between the empirical distributions of the two samples,
204-
$\max_t |F_x(t) - F_y(t)|$,
205-
the test statistic could be written:
204+
$\max_t |F_x(t) - F_y(t)|$, the test statistic could be written:
206205
207206
f = lambda u, v: np.max( \
208-
[abs(sum(u<=v)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\
207+
[abs(sum(u<=val)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\
209208
)
210209
211210
alternative : {'greater', 'less', 'two-sided'}
@@ -299,16 +298,17 @@ def two_sample_shift(x, y, reps=10**5, stat='mean', alternative="greater",
299298
approximating the permutation distribution.
300299
The t-statistic is computed using scipy.stats.ttest_ind
301300
(c) If stat is a function (a callable object), the test statistic is
302-
that function. The function should take a permutation of the pooled
303-
data and compute the test function from it. For instance, if the
304-
test statistic is the Kolmogorov-Smirnov distance between the
305-
empirical distributions of the two samples, $\max_t |F_x(t) - F_y(t)|$,
306-
the test statistic could be written:
301+
that function. The function should take two arguments:
302+
given a permutation of the pooled data, the first argument is the
303+
"new" x and the second argument is the "new" y.
304+
For instance, if the test statistic is the Kolmogorov-Smirnov distance
305+
between the empirical distributions of the two samples,
306+
$\max_t |F_x(t) - F_y(t)|$, the test statistic could be written:
307307
308-
f = lambda u: np.max( \
309-
[abs(sum(u[:len(x)]<=v)/len(x)-sum(u[len(x):]<=v)/len(y)) for v in u]\
308+
f = lambda u, v: np.max( \
309+
[abs(sum(u<=val)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\
310310
)
311-
311+
312312
alternative : {'greater', 'less', 'two-sided'}
313313
The alternative hypothesis to test
314314
keep_dist : bool
@@ -414,15 +414,17 @@ def two_sample_conf_int(x, y, cl=0.95, alternative="two-sided", seed=None,
414414
approximating the permutation distribution.
415415
The t-statistic is computed using scipy.stats.ttest_ind
416416
(c) If stat is a function (a callable object), the test statistic is
417-
that function. The function should take a permutation of the pooled
418-
data and compute the test function from it. For instance, if the
419-
test statistic is the Kolmogorov-Smirnov distance between the
420-
empirical distributions of the two samples, $\max_t |F_x(t) - F_y(t)|$,
421-
the test statistic could be written:
417+
that function. The function should take two arguments:
418+
given a permutation of the pooled data, the first argument is the
419+
"new" x and the second argument is the "new" y.
420+
For instance, if the test statistic is the Kolmogorov-Smirnov distance
421+
between the empirical distributions of the two samples,
422+
$\max_t |F_x(t) - F_y(t)|$, the test statistic could be written:
422423
423-
f = lambda u: np.max( \
424-
[abs(sum(u[:len(x)]<=v)/len(x)-sum(u[len(x):]<=v)/len(y)) for v in u]\
424+
f = lambda u, v: np.max( \
425+
[abs(sum(u<=val)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\
425426
)
427+
426428
shift : float
427429
The relationship between x and y under the null hypothesis.
428430

0 commit comments

Comments
 (0)