-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
62 lines (49 loc) · 1.52 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pandas as pd
import matplotlib.pyplot as pl
n = 100 #number of models generated
T = 179 #time intervals
total = 1 #total function interval
cf = []
cc = []
dg = pd.DataFrame() #all generated models dataframe
df = pd.read_excel('sheet.xlsx') #template sheet
dr = pd.read_excel('result.xlsx') #template sheet (results)
for k in range(n):
dt = total/(T+1) #time interval
t = dt #current time
for i in range(T):
b = 168 *(t**5)*((1-t)**2)
t += dt
df.loc[i,'Beta(t)'] = b
from scipy.stats import norm
x = 0
dev = 0.2
w0 = 0
for i in range(T+1):
w = (x+norm.rvs(scale=dev**2))
w0 += w
df.loc[i,'W(t)'] = w0
for i in range(T+1):
if df.iloc[i,0] + df.iloc[i,1] > 0:
df.loc[i,'D(t)'] = df.iloc[i,0] + df.iloc[i,1]
else:
df.loc[i,'D(t)'] = 0
for i in range(T):
dg.loc[i,k] = df.iloc[i,2]
pl.figure()
dg.plot(legend=True);
pl.xlabel("Time (t)")
pl.ylabel("D(t)")
ds = pd.read_csv('mannlichen.txt',sep = ';') #import of current season as CSV
for i in range(T):
cc.append(ds.iloc[i,2])
from scipy.stats import pearsonr
for i in range(n):
for j in range(T):
cf.append(dg.iloc[j,i])
z = pearsonr(cc,cf)
dr.loc[i,'Correlation'] = z[0]
dr.loc[i,'Model Number'] = i
cf.clear()
dr.sort_values(by=['Correlation'],inplace=True, ascending=False)
print('General Accuracy: (full season only)',dr['Correlation'].mean())