9.Write python program to demonstrate statistical testing


from scipy.stats import ttest_1samp
import numpy as np

ages = np.genfromtxt("ages.csv")
print(ages)

mu = np.mean(ages)
print(mu)

print("Age 30", ttest_1samp(ages,30))
print("Age 3", ttest_1samp(ages,3))

from scipy.stats import ttest_ind
import numpy as np

week1 = np.genfromtxt("week1.csv",  delimiter=",")
week2 = np.genfromtxt("week2.csv",  delimiter=",")

week1_mean = week1.mean()
week2_mean = week2.mean()

print("Week 1 Sample Mean:", week1_mean)
print("Week 2 Sample Mean:", week2_mean)

pval = ttest_ind(week1,week2)
print(pval)

if pval[1] < 0.05:
    print("pval is ", pval[1], "Null Hypothesis Rejected - samples are statistically different")
else:
    print("pval is ", pval[1], "Null Hypothesis Accepted - samples are NOT statistically different")
   
   

Post a Comment

0 Comments