from funclib.variables import *

hodnoty = np.loadtxt("funclib/hodnoty.txt")
s_data = (hodnoty[:,2])
func_data = (hodnoty[:,3])
size = len(s_data)

def func_op2(s, A_x, B_x):
    return ((A_x/F_pi**2 +B_x/(F_pi**2) *(s - s_0))**2)

popt, pcov = curve_fit(func_op2, s_data, func_data)

print("A_x, B_x : " + str(popt))

perr = np.sqrt(np.diag(pcov))
print("error " + str(perr))

cor = np.zeros((2,2))
for i in range (2):
    for j in range (2):
     cor[i,j] = abs(pcov[i,j] * 1/(np.sqrt(pcov[i,i] * pcov[j,j])))
     
print("Correlation matrix")    
print(cor)

