I'm looking to generate some statistics about a model I created in python. I'd like to generate the t-test on it, but was wondering if there was an easy way to do this with numpy/scipy. Are there any good explanations around?
For example, I have three related datasets that look like this:
[55.0, 55.0, 47.0, 47.0, 55.0, 55.0, 55.0, 63.0]
Now, I would like to do the student's t-test on them.
Typically is set to 0 and the 3rd hypothesis is being tested, i.e. there is no difference between the groups. The test statistic is the t value and can be calculated using the following formula: t = ( x ¯ 1 − x ¯ 2 ) − D 0 s p 1 n 1 + 1 n 2.
To find the t value: Subtract the null hypothesis mean from the sample mean value. Divide the difference by the standard deviation of the sample. Multiply the resultant with the square root of the sample size.
We can calculate the t-test on these samples using the built in SciPy function ttest_ind().
In a scipy.stats package there are few ttest_...
functions. See example from here:
>>> print 't-statistic = %6.3f pvalue = %6.4f' % stats.ttest_1samp(x, m) t-statistic = 0.391 pvalue = 0.6955
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With