Search code examples
scipyt-testhypothesis-test

One-Tailed Two Sample T-Test


I have a two sample with the size of 15 data points. Samples are blood pressures before and after the medication. I want to hypothesis testing for my data.

before = np.array([12, 11, 10, 7 , 9, 9.5, 10, 12, 15, 10, 11, 11, 12, 13, 10]) 
after = np.array([10, 10, 9, 5 , 7, 9, 7, 10, 13, 9, 9, 10, 11, 11, 12])

I want to perform t test.

How can I conclude that the my drug is working and the blood pressure of the patients drop after the medication by looking at the scipy ttest function outputs.

stats.ttest_rel(a=after, b=before)
Ttest_relResult(statistic=-4.63809044739016, pvalue=0.00038365801592652317)

does having a statistics value lesser than 0 means that the first group is has more probability of having higher blood pressure.

Thank you.


Solution

  • The test statistic (-4.63809044739016) is computed as follows:

    t = d̅ / (s / sqrt(n))

    where

    • d̅ is the sample mean of the differences (between each pair of observations)
    • s is the sample standard deviation of the differences
    • n is the sample size

    t is negative because the blood pressures after the medication are on average lower than those before the medication.

    Under the null hypothesis (that true mean difference is zero), the test statistic t follows a t-distribution with n-1 (i.e. 14) degrees of freedom.

    The pvalue (0.00038365801592652317) is the probability of observing a value at least as extreme as t (if the null hypothesis is true). If the pvalue is very small (usually < 0.05 or < 0.01), which is the case here, then the null hypothesis is rejected and we can conclude that there is strong evidence that the blood pressure is lower after medication.