From 95ccdc1a6f5f9d8b5be359eed95bc96f37fd0fd6 Mon Sep 17 00:00:00 2001 From: "Philip B. Stark" Date: Thu, 9 May 2019 12:09:21 -0700 Subject: [PATCH] ENH: changed Fisher's calculation for stability; corrected typo in Kolmogorov-Smirnov function --- permute/core.py | 2 +- permute/npc.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/permute/core.py b/permute/core.py index de11a7c3..984e0c5d 100644 --- a/permute/core.py +++ b/permute/core.py @@ -205,7 +205,7 @@ def two_sample(x, y, reps=10**5, stat='mean', alternative="greater", the test statistic could be written: f = lambda u, v: np.max( \ - [abs(sum(u<=v)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\ + [abs(sum(u<=val)/len(u)-sum(v<=val)/len(v)) for val in np.concatenate([u, v])]\ ) alternative : {'greater', 'less', 'two-sided'} diff --git a/permute/npc.py b/permute/npc.py index a3e6bdd4..2764e998 100644 --- a/permute/npc.py +++ b/permute/npc.py @@ -29,7 +29,7 @@ def fisher(pvalues): float Fisher's combined test statistic """ - return -2 * np.log(np.prod(pvalues)) + return -2 * np.sum(np.log(pvalues)) def liptak(pvalues): @@ -287,4 +287,4 @@ def fwer_minp(pvalues, distr, combine='fisher', alternatives='greater'): pvalues_adjusted[jj] = np.max([next_pvalue, pvalues_adjusted[jj-1]]) pvalues_adjusted[j-1] = np.max([pvalues_ord[j-1], pvalues_adjusted[j-2]]) pvalues_adjusted = pvalues_adjusted[np.argsort(pvalues)] - return pvalues_adjusted \ No newline at end of file + return pvalues_adjusted