Skip to content

Instantly share code, notes, and snippets.

@HeenaR17
Created March 23, 2021 09:18
Show Gist options
  • Save HeenaR17/e0f3719401142ad92408b247261e7c86 to your computer and use it in GitHub Desktop.
Save HeenaR17/e0f3719401142ad92408b247261e7c86 to your computer and use it in GitHub Desktop.
marks=[10,20,30,22,33,44,15,50,46,25,45,25,33,12,45,34,31,30,30,30]
import numpy as np
meanvalue=np.mean(marks)
print(meanvalue)
#Output: 30.5
#Taking sample from our data
sample_size=8
marks_sample=np.random.choice(marks,sample_size)
marks_sample
#array([33, 44, 20, 25, 12, 33, 30, 34])
from scipy.stats import ttest_1samp
ttest, p_value=ttest_1samp(marks_sample,30.5)
print(p_value)
#0.6525151388366586
if p_value >= 0.5:
print("Accept null hypothesis")
else:
print("Reject null hypothesis")
#Accept null hypothesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment