from scipy import stats X = [156.89, 163.05, 169.68, 173.16, 174.42, 150.64, 135.57, 136.45, 148.80, 176.60, 177.22, 152.15, 166.17, 182.82, 173.73, 175.57, 177.31, 148.29, 168.33, 156.50] t_statistic, p_value = stats.ttest_1samp(a=X, popmean=160) print("t-statistic: ", t_statistic) print("p-value: ", p_value)
Here, we are given the weights of a sample, and we need to determine whether the sample mean is statistically different from a known value of 160 gm.
The output of the above program will be like the following:
t-statistic: 1.0017194659421818 p-value: 0.32906680206675576
Now, let’s say our significance level alpha is 0.05. Since the calculated p-value is more than 0.05, we fail to reject the null hypothesis. In other words, in this case, the sample mean is not statistically different from 160 gm.






0 Comments