Trying to test code creating P-value manually against SciPy. The Scipy Documentation isn't the best, which makes it tought to know for sure what to do.
I am getting the correct t-stat and P-value with SciPy, but I'm not able to replicate the correct p-value manually - A friend steered me to
scipy.stats.t.ppf - but I'm not getting a p-value from it.
What is the correct way to do
def t_test(sample, mu): mean = np.mean(sample) var = np.var(sample) sem = (var / len(sample)) ** .5 t = abs(mu - mean)/sem df = len(sample) - 1 p = scs.t.ppf(.95, df) return (t, p)
for testing, I'm using the following sample set and sample mu.
sample = [4.15848606, 3.86146363, 4.31545726, 3.3748772, 4.67023082, 4.45950272, 3.85894915, 4.41089417, 3.82360986, 3.79889443, 4.75884172, 3.27100914, 4.08939402, 4.08904694, 5.62589842, 3.71445656, 3.58463792, 4.42426443, 3.9671448 , 4.39339124] mu = 4.123