[med-svn] [python-mne] 69/376: partial previous commit

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:22:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

yoh pushed a commit to annotated tag v0.1
in repository python-mne.

commit 611a97c843827b21e3058298df044b3cf8433bef
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Sun Feb 13 22:20:23 2011 -0500

    partial previous commit
---
 mne/stats/permutations.py            | 11 ++++++-----
 mne/stats/tests/test_permutations.py |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/mne/stats/permutations.py b/mne/stats/permutations.py
index 6667962..df4aca7 100644
--- a/mne/stats/permutations.py
+++ b/mne/stats/permutations.py
@@ -63,10 +63,11 @@ def permutation_t_test(X, n_permutations=10000, tail=0):
         Data of size number of samples (aka number of observations) times
         number of tests (aka number of variables)
 
-    n_permutations : int or 'exact'
-        Number of permutations. If n_permutations is 'exact' all possible
-        permutations are tested (2**n_samples).
-        If n_permutations >= 2**n_samples then the 'exact test is performed'
+    n_permutations : int or 'all'
+        Number of permutations. If n_permutations is 'all' all possible
+        permutations are tested (2**n_samples). It's the exact test, that
+        can be untractable when the number of samples is big (e.g. > 20).
+        If n_permutations >= 2**n_samples then the exact test is performed
 
     tail : -1 or 0 or 1 (default = 0)
         If tail is 1, the alternative hypothesis is that the
@@ -103,7 +104,7 @@ def permutation_t_test(X, n_permutations=10000, tail=0):
     if do_exact:
         perms = bin_perm_rep(n_samples, a=1, b=-1)[1:,:]
     else:
-        perms = np.sign(np.random.randn(n_permutations, n_samples))
+        perms = np.sign(0.5 - np.random.rand(n_permutations, n_samples))
 
     mus = np.dot(perms, X) / float(n_samples)
     stds = np.sqrt(X2[None,:] - mus**2) * dof_scaling # std with splitting
diff --git a/mne/stats/tests/test_permutations.py b/mne/stats/tests/test_permutations.py
index 640bbc6..3161dd1 100644
--- a/mne/stats/tests/test_permutations.py
+++ b/mne/stats/tests/test_permutations.py
@@ -28,7 +28,7 @@ def test_permutation_t_test():
     assert_array_equal(is_significant, [False, False, False, False, False])
 
     X = np.random.randn(18, 1)
-    p_values, T0, H0 = permutation_t_test(X[:, [0]], n_permutations='exact')
+    p_values, T0, H0 = permutation_t_test(X[:, [0]], n_permutations='all')
     T0_scipy, p_values_scipy = stats.ttest_1samp(X[:, 0], 0)
     assert_almost_equal(T0[0], T0_scipy, 8)
     assert_almost_equal(p_values[0], p_values_scipy, 2)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git



More information about the debian-med-commit mailing list