1

I would like to minimize the following function (16)enter image description here

Note that the phi function is defined as follows: enter image description here

My Problem I then try to use the

from scipy.optimize import minimize

to minimize function (16). However, (16) has an the infinite sum from (15). How can I implement this in Python? Can the optimize function minimize an infinite sum? Right now I just defined the formula, set the infinite sum to sum only until n = 10.

def formula(x):
    return -sum(math.log(sum(1/math.sqrt(
           2*math.pi*(x[1]**2/252+n*x[4]**2))*math.exp(
           -(y-(x[0]/252+n*x[3]))**2/(2*(x[1]**2/252
           +n*x[4]**2)))*math.exp(
           -x[2]/252)*(x[2]/252)**n/math.factorial(n) 
           for n in range(1,10))) for y in difference)

guess = np.array([0.1,0.1,0.1,0.1,1])

results = minimize(formula, guess, method = 'Nelder-Mead', options={'ftol':0.01, 'xtol':0.01})
James
  • 32,991
  • 4
  • 47
  • 70
Whizkid95
  • 271
  • 4
  • 14
  • It's already been asked as far as infinite sum is concerned. https://stackoverflow.com/questions/36382411/how-to-perform-infinite-sum-numerically-in-python – Radek D Jul 06 '22 at 08:57

0 Answers0