Skip to content

Instantly share code, notes, and snippets.

@datatalking
Created April 14, 2023 16:06
Show Gist options
  • Save datatalking/1aa0a6d8af653734ae5409267bc6bb62 to your computer and use it in GitHub Desktop.
Save datatalking/1aa0a6d8af653734ae5409267bc6bb62 to your computer and use it in GitHub Desktop.
t-test of two distributions null vs alternative
import seaborn as sns, numpy as np
from scipy import stats
import numpy as np
import statistics
Null_Hypothesis = "YieldA = YieldB"
Alternate_Hypothesis = "YieldA != YieldB"
Vx1_1 = [4618, 3094, 158, 4701, 2692, 2012, 2569, 1233, 1895, 181]
Vx2_1 = [3352, 174, 1661, 1984, 1518, 3594, 3346, 1834, 3300, 3816]
print("The r stat = ", r.statistic)
print("The r pvalue = ", r.pvalue)
print(r.statistic, r.pvalue)
A_mean_pts = statistics.mean(Vx1_1)
B_mean_pts = statistics.mean(Vx2_1)
print("Mean Points for A =", A_mean_pts)
print("Mean Points for B =", B_mean_pts)
tstat, pval = stats.ttest_ind(YieldA['pts'], 110)
print("The T Stat = %.2f, and the P Value = %.4f" % (tstat, pval))
print("T Stat = %.2f, P Value = %.4f" % (tstat, pval))
if pval < 0.03:
print("Reject the null hypothesis")
else:
print("Accept the null hypothesis")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment