2

I am trying to minimize a simple equation with sklearn minimizer but, weirdly, it seems the minimizer does not even try and send me back really bad result.

The equation has two different variable that I'd like to optimize for the formula to be minimized, here is the code I use:

from scipy.stats import poisson
import scipy.optimize

def objective_function(guess):
    x = guess[0]
    y = guess[1]
    return poisson.pmf(1,x) * poisson.pmf(2,y) - 1/9.4 + poisson.pmf(1,x) * poisson.pmf(3,y) - 1/14

initialGuess = [0.0, 0.0]
scipy.optimize.minimize(objective_function, initialGuess)

and here is the result I guess from the minimizer

 fun: -0.1778115501519757
 hess_inv: array([[1, 0],
       [0, 1]])
      jac: array([0., 0.])
  message: 'Optimization terminated successfully.'
     nfev: 3
      nit: 0
     njev: 1
   status: 0
  success: True
        x: array([0., 0.])

Trying on my side I can clearly see that it is not even close the best answer as [1, 1.5] will for example return me -0.03.

Is there a big thing I am missing with the optimizer from scipy?

Jacob Lee
  • 4,405
  • 2
  • 16
  • 37
natm
  • 21
  • 1

0 Answers0