[SciPy-user] minization of multivariable function

josef.pktd@gmai... josef.pktd@gmai...
Sat Jan 24 14:46:55 CST 2009


Your weighting matrix doesn't look very good, the values are very  small

>>> Wm0 = matpoids([0.1, 0.5, 0.3])
Optimization terminated successfully.
         Current function value: 0.000012
         Iterations: 33
         Function evaluations: 86
>>> numpy.diag(Wm0)
array([  9.46553187e+05,   2.07547296e+10,   2.34384235e+10,
         4.98660601e+14])


when I use the identity matrix as the weighting matrix, the
optimization converges pretty fast with this result

>>>
Optimization terminated successfully.
         Current function value: 0.000000
         Iterations: 21
         Function evaluations: 51
[ 0.12207186 -0.0352489   0.36672972]



Here are the changes, how I ran it:

def g(xi,W):
    L=Heston(xi[0], xi[1], xi[2])
    G=numpy.matrix(conditions(xi[0], xi[1], xi[2], L))
    return abs(float(G*(W*(G.T))))

def optiGMM(xi1,W):
    return fmin(g, xi1,args=(W,),xtol=0.001, ftol=0.0001, maxiter=300,
maxfun=None, full_output=0, disp=1, retall=0, callback=None)


#xi0 = [0.1, 0.5, 0.3]
xi0 = [ 0.1243751,  -0.03429623,  0.37577618]
#W=matpoids(xi0)
W = numpy.eye(4)
import time
t = time.time()
print optiGMM(xi0,W)
print time.time() - t


More information about the SciPy-user mailing list