Re: In need of vectorization help



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



.



Relevant Pages

  • Re: sram vs sdram
    ... Cost vs. capacity vs. complexity vs. power ... Choose what fits your ... Speed you can get equivalent speeds ...
    (comp.arch.embedded)
  • Re: Connecting external propane appliance to existing RV tank.
    ... hose you'll need and whatever hose fits will need an end cap that fits ... Maybe you can look at a fitting and determine the correct mating size? ... BBROYGBVGW I used to order them by the thousands when I managed an electronics dept. ...
    (rec.outdoors.rv-travel)
  • Re: curve fitting using self-defined function
    ... My professor and I are having a question about fitting a set of data using a self-defined function, ... "For some nonlinear library models, ... data and model may lead to different fitted coefficients. ... Nonlinear curve fitting is often highly dependent on the initial values for the coefficients, in the sense that the sum of suqared residuals criterion has multiple local minima, and many of them are not good fits to the data at all. ...
    (comp.soft-sys.matlab)
  • Re: (TiT) Lakhon, Thai series
    ... Mort Beauregard ... Suddenly it all fits. ... When things start fitting for the misfits, ...
    (soc.culture.thai)
  • Re: OT - BT iPlate for ADSL speed improvement
    ... Over the past few months speeds here have been at most 4.2 Mb/s, ... of anyone's speed _suffering_ as a result of fitting one of these. ... master socket. ...
    (uk.comp.sys.mac)