Skip to content

Instantly share code, notes, and snippets.

View aditya0811's full-sized avatar
🏠
Working from home

Aditya Mahajan aditya0811

🏠
Working from home
View GitHub Profile
@aditya0811
aditya0811 / .py
Created June 4, 2019 08:11
dofstudenttest
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
@aditya0811
aditya0811 / .py
Created June 3, 2019 15:18
sampleone
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
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
@aditya0811
aditya0811 / .py
Last active June 3, 2019 07:06
welsh's
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
@aditya0811
aditya0811 / .py
Last active June 4, 2019 08:07
student ttest_auto
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)
@aditya0811
aditya0811 / try_arima_exog.ipynb
Created May 16, 2019 12:28 — forked from josef-pkt/try_arima_exog.ipynb
ARIMAX and seasonal splines
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.