4

scipy documentation describes a module [scipy.stats.permutation_test].1

when I try using this module in Jupyter Notebook, as shown below, I get:

"AttributeError: module 'scipy.stats' has no attribute 'permutation_test'".

Looking at all the attributes for scipy.stats in the Notebook, permutation_test is not listed. Does the permutation_test module really exist in scipy, or is this an Anaconda distribution issue?

import numpy as np
import scipy.stats as sps

def stat_q25(x, y):
    return np.quantile(x, 0.25) - np.quantile(y, 0.25)

test_q25 = sps.permutation_test(data = (x, y), statistic = stat_q25, alternative = 'greater')
PeterG
  • 41
  • 2
  • Make sure you are looking at docs for the version of scipy you have installed. It's possible that they added or removed that function at some point. – 0x5453 Jun 27 '22 at 21:07
  • 2
    It's a recent addition. You'll need scipy version >= 1.8.0. You say you are using Anaconda, so this might help: https://anaconda.org/conda-forge/scipy. – AlexK Jun 27 '22 at 23:07

1 Answers1

1

Probably your python version is too low. If you update it to higher version, for example 3.8, you can install a higher version of scipy, permutation_test will be included.

I had the same issue and solved it recently.

qzw0004
  • 11
  • 1