Wednesday, May 27, 2020

Python for MBA's- One sample 't' test

T test

This is the most common hypothesis testing statistical test used in social science.
Today we will learn how to calculate One sample 't ' test using Python.

Problem:

Let us take Virat Kohli's  four  innings score in 2020 in New zealand in T 20 matches
They are
11,
38,
11,
45
His career average in T20 Internationals is 50.80
Now the hypothesis is

Virat Kohli's average in T20's in New Zealand 2020 series  significantly differs from career T 20 International average.

The Python code is given below.


import numpy as np
from scipy.stats import norm
from scipy import stats
Virat_t20I=(11,38,11,45)
# Perform t-test and print result
t_result=stats.ttest_1samp(Virat_t20I, 50.8)
print(t_result)

# Test significance
alpha= 0.05
if (t_result[1] < alpha):
    print("mean value of Virat_T20I differs from given value")
else:
  print("No significant difference found")
 

Solution:

Ttest_1sampResult(statistic=-2.7523096064356434, pvalue=0.07060545196814848)
No significant difference found
 
 
 

 

No comments:

Post a Comment