[SciPy-user] fmin won't optimize

Yaroslav Bulatov yaroslavvb at gmail.com
Thu Nov 4 19:33:07 CST 2004


I'm fitting Gibbs distribution to data using maximum likelihood. If I
use fmin_powell, it works, but when I use fmin, it terminates after 1
iteration regardless of starting point. The log-likelihood function is
convex. Any idea why this would happen?

The code below terminates with likelihood 4.158883, whereas the
minimum is 3.296169

# Train simple 3 parameter Gibbs Distribution

import math
from scipy import *
from scipy.optimize import *

# Negative log-likelihood
def neg_ll(lambdas):
  unnormalized = lambda(x):
  Z = sum([unnormalized(x) for x in [(0,0),(0,1),(1,0),(1,1)]])
  ll = 0
  for x in train_set:
  return -ll

def main():
  x0 = [0,0,0]
  xopt = fmin(neg_ll, x0)
  print 'Before training: %f' %(neg_ll(x0),)
  print 'After training: %f' %(neg_ll(xopt),)
if __name__=='__main__': main()

More information about the SciPy-user mailing list