[SciPy-User] help with leastsq and fmin

Joses Ho joses.ho@well.ox.ac...
Wed Sep 8 17:06:33 CDT 2010


Hi,
I am trying to fit to my qPCR data 
an exponential function 
where each successive y-value depends on the 
previous v-value in the following fashion:
y[n]  =  y[n-1] + k ln (1 + (y[n-1]/k) + b
where y[n] = current y-value being evaluated 
and y[n-1] = previous y-value

I therefore have three values to fit - y0 (starting value of y), k, and b.

I define a residuals function where I 
compute 20 values of y,
 given an initial estimate of y0, k and b, and 
then subtract these from my 20 
measured values of y. 

I have tried to use scipy.optimize.leastsq on the 
above residuals function, but it doesn't seem to be 
converging on the correct values of y0,k and b.
I have tried scipy.optimize.fmin on the same function, 
but I get the following error:
...fsim[0] = func(x0)
...ValueError: setting an array element with a sequence.
which seems to me that it refuses to accept the x0 array 
I give to it, consisting of [y0,k,b].

Basically, I am trying to implement the recent method of Boggy and Woolf 
(PLoS 2010) [doi:10.1371/ journal.pone.0012355] in Python. 
I am using SciPy 0.8.0b1 and NumPy 1.4.0 on 
Python 2.6.5 of the Enthought Python Distribution 6.2-2.

Any help here would be very much appreciated! 

Thanks
Joses



More information about the SciPy-User mailing list