Python-110 One Sample T-Test 单样本

2021-06-29  本文已影响0人  RashidinAbdu
1. Introduction:

2. Hypothesis and Interpretation of the results:

If the p-value of our test is greater than alpha = 0.05, we fail to reject the null hypothesis of the test. We do not have sufficient evidence to say that the mean height for this particular species of plant is different from 15 inches.


3. How to do that?
image.png
#pip install scipy
#pip install openpyxl
import pandas as pd

df_sheet_index = pd.read_excel('C:/Users/Mr.R/Desktop/excels/zm.xlsx', sheet_name='1', usecols='C')
print(df_sheet_index)

import scipy.stats as stats
data =df_sheet_index
# or data = [12, 13, 21, 14, 16, 11, 12, 18, 19]
hypothised_mean = 15

#perform one sample t-test
#test whether the mean is equal to the hypothised_mean
test_result = stats.ttest_1samp(a=data, popmean=hypothised_mean)

#print the used data and results 
print('test-data is :', data)
print("The final t-test result is :", test_result)

statistic=array([0.09386465]), pvalue=array([0.92752497])
The t-test statistic is0.09386465 and the corresponding two-sided p-value is0.92752497.


image.png

Reference: https://www.statology.org/one-sample-t-test-python/

上一篇 下一篇

猜你喜欢

热点阅读