Talk:Welch's t-test: Difference between revisions

→‎cannot run python libraries: move to Hailholyghost's talk page (the problem was unrelated to this task)
(→‎cannot run python libraries: move to Hailholyghost's talk page (the problem was unrelated to this task))
 
(19 intermediate revisions by 2 users not shown)
Line 1,203:
 
[[User:Eoraptor|Eoraptor]] ([[User talk:Eoraptor|talk]]) 21:31, 28 December 2017 (UTC)
 
==cannot run python libraries==
 
current numpy/scipy/scipy.stats will not run on my Ubuntu VM:
 
<lang python>
true
Traceback (most recent call last):
File "numpy_scipy_pvalue.py", line 3, in <module>
import scipy.stats
File "/usr/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 344, in <module>
from .stats import *
File "/usr/lib/python2.7/dist-packages/scipy/stats/stats.py", line 173, in <module>
import scipy.special as special
File "/usr/lib/python2.7/dist-packages/scipy/special/__init__.py", line 643, in <module>
from ._ellip_harm import ellip_harm, ellip_harm_2, ellip_normal
File "/usr/lib/python2.7/dist-packages/scipy/special/_ellip_harm.py", line 7, in <module>
from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm
File "scipy/special/_ellip_harm_2.pyx", line 5, in init scipy.special._ellip_harm_2 (scipy/special/_ellip_harm_2.c:7330)
File "/usr/lib/python2.7/dist-packages/scipy/integrate/__init__.py", line 59, in <module>
from ._bvp import solve_bvp
File "/usr/lib/python2.7/dist-packages/scipy/integrate/_bvp.py", line 10, in <module>
from scipy.sparse.linalg import splu
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/__init__.py", line 112, in <module>
from .isolve import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py", line 84, in <module>
def bicg(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, M=None, callback=None):
File "/usr/lib/python2.7/dist-packages/scipy/_lib/_threadsafety.py", line 59, in decorator
return lock.decorate(func)
File "/usr/lib/python2.7/dist-packages/scipy/_lib/_threadsafety.py", line 47, in decorate
return scipy._lib.decorator.decorate(func, caller)
File "/usr/lib/python2.7/dist-packages/scipy/_lib/decorator.py", line 241, in decorate
evaldict, __wrapped__=func)
File "/usr/lib/python2.7/dist-packages/scipy/_lib/decorator.py", line 224, in create
self = cls(func, name, signature, defaults, doc, module)
File "/usr/lib/python2.7/dist-packages/scipy/_lib/decorator.py", line 120, in __init__
formatvalue=lambda val: "", *argspec[:-2])[1:-1])
File "/usr/lib/python2.7/inspect.py", line 871, in formatargspec
return '(' + string.join(specs, ', ') + ')'
AttributeError: 'module' object has no attribute 'join'
</lang>
 
these libraries seem promising, but I can't use them.
 
--[[User:Hailholyghost|Hailholyghost]] ([[User talk:Hailholyghost|talk]]) 15:11, 16 March 2018 (UTC)
:Can you post your own program that attempts to use these libraries? Does it fail when you only import the lib? If not, does the following fail?
 
<pre>
import numpy as np
a = np.array([1,2,3],dtype=float)
np.sum(a)
</pre>
 
[[User:Eoraptor|Eoraptor]] ([[User talk:Eoraptor|talk]]) 17:54, 16 March 2018 (UTC)
 
Hi Eoraptor,
 
I'm trying the same script that you're running, the problem is in scipy.stats I think:
 
<lang python>
import numpy as np
import scipy as sp
import scipy.stats
def welch_ttest(x1, x2):
n1 = x1.size
n2 = x2.size
m1 = np.mean(x1)
m2 = np.mean(x2)
v1 = np.var(x1, ddof=1)
v2 = np.var(x2, ddof=1)
t = (m1 - m2) / np.sqrt(v1 / n1 + v2 / n2)
df = (v1 / n1 + v2 / n2)**2 / (v1**2 / (n1**2 * (n1 - 1)) + v2**2 / (n2**2 * (n2 - 1)))
p = 2 * sp.stats.t.cdf(-abs(t), df)
return t, df, p
welch_ttest(np.array([3.0, 4.0, 1.0, 2.1]), np.array([490.2, 340.0, 433.9]))
(-9.559497721932658, 2.0008523488562844, 0.01075156114978449)</lang>
 
I've installed numpy and scipy, but if I run only the top 3 lines I get the error as well.
1,336

edits