If a function is implemented in python you can easily get its source code:
>>> import inspect
>>> print(inspect.getsource(ttest_1samp))
also inspect.getfile
, returns the path to the file which implements the method/function. As for ttest_1samp
, dropping the doc string this is the source code which should be easy to compare with yours:
def ttest_1samp(a, popmean, axis=0):
"""
... doc string ...
"""
a, axis = _chk_asarray(a, axis)
n = a.shape[axis]
df = n - 1
d = np.mean(a, axis) - popmean
v = np.var(a, axis, ddof=1)
denom = np.sqrt(v / float(n))
t = np.divide(d, denom)
t, prob = _ttest_finish(df, t)
return t,prob
def _ttest_finish(df,t):
"""Common code between all 3 t-test functions."""
prob = distributions.t.sf(np.abs(t), df) * 2 # use np.abs to get upper tail
if t.ndim == 0:
t = t[()]
return t, prob