Re: MPFITFUN [message #50945 is a reply to message #48702] |
Fri, 27 October 2006 11:20  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
nolan.smith1@gmail.com wrote:
> Hello,
>
> I have a little problem with mpfitfun.pro and I was wondering if anyone
> has any suggestions
> on how to solve it. I am using mpfitfun to perform a fit in a function
> that is the sum of 2 exponentials
> and a quadratic. The fit works very good but the result is giving me
> some negative values Y values
> which physically do not make sense (the numbers on Y are numbers per
> bin so they are positive).
> The negative values are only 3 (out of the 50 bins) and they never go
> lower than -1, so they do not go very low. Is there any way to limit
> the Y to be positive (like we do with the parameters?).
The simplest approach is simply to treat fitted values less than 0 as
if they were 0.
A more complicated approach would be to parameterize your model in such
a way that it's easy to impose non-negative results as a constraint on
model parameters. For instance, instead of using a*x^2+b*x+c for the
quadratic part of your model, use a*(x-b)^2+c, so that non-negativety
can be imposed by the requirements that "a GE 0 and c GE 0".
|
|
|