statistics in python

T-test uses a statistical examination of two population means.
To perform t-test in python, scipy package is good tool to do that.
For example
I have data, that collected two times.
1st time [54.3, 55.2, 55.0, 56.4, 53.1, 53.1]
2nd time [56.5, 54.8, 58.2, 57.8, 59.0, 60.7]
Is there the difference in means of two data ?
in python…

import scipy.stats as stats
a = [54.3, 55.2, 55.0, 56.4, 53.1, 53.1]
b = [56.5, 54.8, 58.2, 57.8, 59.0, 60.7]
res = stats.ttest_rel(a,b)

res has two data, 1. t-value, 2. provability. Like this.

In [10]: stats.ttest_rel(a,b)
Out[10]: (array(-2.7458856580188598), 0.040507701177115191)

Easy to do it. 😉

Advertisements