-
Notifications
You must be signed in to change notification settings - Fork 43
/
KS_D_statistics.py
35 lines (23 loc) · 1.18 KB
/
KS_D_statistics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
df = pd.read_csv("/Users/tatev/Downloads/data.csv", encoding='ISO-8859-1')
def get_KS_stat_onesided(long_or_short, sector, df):
print("D_stat one sided that pre is smaller than post for sector", sector)
print("The window type", long_or_short)
if sector == 0:
if (long_or_short == "long"):
KS_stat = stats.kstest(df["diff_BC"], 'norm', alternative= "less")
else:
KS_stat = stats.kstest(df["diff_DC"], 'norm', alternative= "less")
else:
if (long_or_short == "long"):
KS_stat = stats.kstest(df[df["Sector_Group"] == sector]["diff_BC"], 'norm')
else:
KS_stat = stats.kstest(df[df["Sector_Group"] == sector]["diff_DC"], 'norm')
print(KS_stat)
get_KS_stat_onesided("long", 0 , df)
print("-----------------------------------------------------------------------")
get_KS_stat_onesided("long", 1 , df)
print("-----------------------------------------------------------------------")
get_KS_stat_onesided("short", 0, df)
print("-----------------------------------------------------------------------")
get_KS_stat_onesided("short", 1, df)
print("-----------------------------------------------------------------------")