This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num_a,num_b=len(a),len(b) | |
dof=((a.var()/num_a) + (b.var()/num_b))**2/((a.var()**2/(num_a**2 * (num_a-1)))+(b.var()**2/(num_b**2 * (num_b-1)))) | |
print(dof) | |
>>>20.059045836684753 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
import numpy as np | |
a=np.array([27.5, 21.0, 19.0, 23.6, 17.0, 17.9, 16.9, 20.1, 21.9, 22.6, 23.1, 19.6, 19.0, 21.7, 21.4,22,23,32.5,43.4,12.4,23.4]) | |
pop_mean=27.5 | |
num_a=len(a) | |
test_statistic= (a.mean()-pop_mean)/(a.std()/sqrt(num_a)) | |
print(test_statistic) | |
>>>-3.855 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=np.array([27.5, 21.0, 19.0, 23.6, 17.0, 17.9, 16.9, 20.1, 21.9, 22.6, 23.1, 19.6, 19.0, 21.7, 21.4]) | |
b=np.array([27.1, 22.0, 20.8, 23.4, 23.4, 23.5, 25.8, 22.0, 24.8, 20.2, 21.9, 22.1, 22.9, 20.5, 24.4]) | |
num_a,num_b=len(a),len(b) | |
print(a.var(),b.var()) | |
>>>7.342933333333334, 3.5584888888888906 | |
#Finding dof | |
dof=((a.var()/num_a) + (b.var()/num_b))**2/((a.var()**2/(num_a**2 * (num_a-1)))+(b.var()**2/(num_b**2 * (num_b-1)))) | |
print(dof) | |
>>>24.988529290231416 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=np.array([27.5, 21.0, 19.0, 23.6, 17.0, 17.9, 16.9, 20.1, 21.9, 22.6, 23.1, 19.6, 19.0, 21.7, 21.4]) | |
b=np.array([27.1, 22.0, 20.8, 23.4, 23.4, 23.5, 25.8, 22.0, 24.8, 20.2, 21.9, 22.1, 22.9, 20.5, 24.4]) | |
num_a,num_b=len(a),len(b) | |
print(a.var(),b.var()) | |
>>>7.342933333333334, 3.5584888888888906 | |
dof=((a.var()/num_a) + (b.var()/num_b))**2/((a.var()**2/(num_a**2 * (num_a-1)))+(b.var()**2/(num_b**2 * (num_b-1)))) | |
print(dof) | |
>>>24.988 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a=np.array([27.5, 21.0, 19.0, 23.6, 17.0, 17.9, 16.9, 20.1, 21.9, 22.6, 23.1, 19.6,23]) | |
b=np.array([27.1, 22.0, 20.8, 23.4, 23.4, 23.5, 25.8, 22.0, 24.8, 20.2, 21.9, 22.1, 22.9, 20.5, 24.4]) | |
from scipy.stats import ttest_ind | |
stat, p = ttest_ind(a, b,equal_var=True) | |
print(stat) | |
>>>-2.0754319784177606 | |
#Though here variance of sample is not equal but we assumend it to be equal for conducting students t-test, | |
#(for unequal variance we will discuss Welsch's t-test later) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.