I want to get 3 parameters from the given equation. hence i want to optimize it. But after executing the code i am getting error : "IndexError: index 3 is out of bounds for axis 0 with size 3" and the traceback is coming from the --------> minimize.(fnz,..... ) any clue where can i correct it?
import numpy as np
import math
import pandas as pd
from scipy.optimize import minimize
import math
TTF =[50,94, 196, 268, 290, 329, 332, 347, 544, 732, 811, 899, 945, 950, 955, 991 ,1013 ,1152 ,1362
,1459 ,1489 ,1512 ,1525 ,1539]
Repair = pd.DataFrame(TTF, columns = ["TTF"])
for i in range(0,len(Repair["TTF"])-2):
T[i+1] = Repair["TTF"][i+1] - Repair["TTF"][i]
T[0] = Repair["TTF"][0]
def Vir(temp):
V1 = np.ones(23)
V1[0] = T[0]*temp
for i in range(1,(len(T))):
V1[i]=(temp*(T[i]+V1[i-1]))
return(V1)
I want to get 3 parameters from the given equation. hence i want to optimize it. But after executing the code i am getting error : "IndexError: index 3 is out of bounds for axis 0 with size 3" and the traceback is coming from the --------> minimize.(fnz,..... ) any clue where can i correct it?
import numpy as np import math import pandas as pd from scipy.optimize import minimize import math TTF =[50,94, 196, 268, 290, 329, 332, 347, 544, 732, 811, 899, 945, 950, 955, 991 ,1013 ,1152 ,1362 ,1459 ,1489 ,1512 ,1525 ,1539] Repair = pd.DataFrame(TTF, columns = ["TTF"]) for i in range(0,len(Repair["TTF"])-2): T[i+1] = Repair["TTF"][i+1] - Repair["TTF"][i] T[0] = Repair["TTF"][0]
def Vir(temp):
theta =np.array([[0.003],[0.03],[0.4]]) def fnz(theta):
x0 = np.array([theta[0],theta[1],theta[2]] bnds = ((0.0000001, 1), (0.000001, 5),(0.0001,1)) results = minimize(fnz, x0, method='SLSQP', bounds = bnds)