Re: In need of vectorization help
- From: "Seamus " <s.holden1@xxxxxxxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 00:05:03 +0000 (UTC)
Hi Darren,
I found this post when trying to speed up my own fitting
code. My application is quite similar - i am carrying out
gaussian fits to fluorescent molecules on 512x512xN images
using lsqcurve fit.
Several things I have found to increase the speed of my program:
- Using the data from previous fits, as discussed already
- Reducing the termination tolerance 'TolFun'
The matlab default is 1e-6. Depending on the noise and
uncertainty on your data, and by carrying out stringent
testing to ensure the quality of your fits are not affected,
it may be possible to increase your run speed by almost an
order of magnitude. I was able to decrease TolFun to 1e-2
whilst still mainting good accuracy.
- Analytically computing the Jacobian for your function
This _significantly_ speeds up fitting. lsqcurvefit
large scale method computes the next step in minimisation of
the function based on the partial derivatives of the
function wrt to the free parameters. By default it does this
using finite difference methods. However, if your function
is differentiable (which in your case it is) by supplying
the analytic differentials of your function, you
significantly decrease the time to calculate the gradients,
and thus increase the speed of your code. I got a speed
increase of ~1/3.
The function help outlines how to do this, but its not
terribly clear, if you would like more help on it let me know.
As a question to anyone reading this, having carried out
these steps, I believe I am pretty much running my fits as
fast as matlab will let me, so I am starting to think I will
have to think of another method.
Does anyone know whether any of the other fit
functions are entirely inbuilt, ie compiled and therefore
faster than lsqcurvefit, which is primarily written in
m-code? Or is anyone aware of any eg. mex code or something
similar (compiled) which may be a viable alternative fitting
option?
Regards
Seamus Holden
.
- Follow-Ups:
- Re: In need of vectorization help
- From: Nicolas
- Re: In need of vectorization help
- Prev by Date: Re: Solving a quadratic Lagrange interpolant , How ?
- Next by Date: manejo de matlab via web
- Previous by thread: Associate M-file with Matlab on Mac OSX?
- Next by thread: Re: In need of vectorization help
- Index(es):
Relevant Pages
|