Jupyter code in python #9288
Unanswered
jamoforeal
asked this question in
Q&A
Replies: 1 comment
-
Did you import the numpy and scipy libraries? and you need a if p_value < 0.05: and your a and b is creating a list of 30 with values from 20 to 50 and not a list of 50 as you say in the code comments |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please can anyone help me identify the error in this code in my jupyter notebook
#Let's generate a random dataset that meets the above assumptions
import random
We will use random data for the samples and label them as 'a' and 'b' respectively
a = [random.gauss(50, 20) for x in range(30)] #a variable with a list of 50
b = [random.gauss(55, 15) for x in range(30)]
#If we assume the population mean is 40
#Null hypothesis is the sample mean = population mean(40)
#alpha=0.05
#Therefore, p<0.05 (reject null hypothesis)
#Let's test it for sample a
t_stat, p_value = stats.ttest_1samp(a, 40, axis=0)
#Print the t-stat and the p-value
print("T-statistic:", t_stat)
print("P-value:", p_value)
print(np.mean(a))
Beta Was this translation helpful? Give feedback.
All reactions