forcing fit parameters into a range

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

forcing fit parameters into a range

Gelman, Laurent
Hi everybody,

Is it possible, when using the fit function, not only to give the initial values for the parameters, but also to force these to stay within a given range, e.g. never get negative or positive... ?

Thanks for your help,

Best regards,

Laurent.


_____________________________________________
Laurent Gelman, PhD
Head of Facility for Advanced Imaging and Microscopy
(Light Microscopy)

Friedrich Miescher Institut
WRO 1066.2.16
Maulbeerstrasse 66
CH-4058 Basel
Fix: +41 (0)61 696 35 13
Mobile: +41 (0)79 618 73 69
Fax: +41 (0)61 697 39 76

www.fmi.ch<http://www.fmi.ch/>
www.microscopynetwork.unibas.ch/<http://www.microscopynetwork.unibas.ch/>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: forcing fit parameters into a range

Michael Schmid
On Oct 28, 2013, at 12:57, Gelman, Laurent wrote:

> Hi everybody,
>
> Is it possible, when using the fit function, not only to give the initial values for the parameters, but also to force these to stay within a given range, e.g. never get negative or positive... ?

________________________________________________________________

Hi Laurent,

simply write your function such that it returns NaN (not a number) if it enters the forbidden range.
For this purpose, it's nice that the 'custom fit' function can also have a more complex form consisting of several statements.

Example:
  if (b < 0) y = NaN ; else y = a + b*x + c*x*x;

If you use one of the built-in fit functions, note that the fit procedure usually gets less efficient when converting it to a 'custom' function.  For the built-in functions, ImageJ splits off parameters that are mere factors and offsets and determines them by linear regression.  This is not done for custom functions.

Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html