Least square fitting - exponential curve - negative $y$ value

362 Views Asked by At

I need to fit an exponential curve through a given dataset. The curve is defined by: $y=A\exp(Bx)$ so I need to estimate $A$ and $B$.

However my $y$ values are all negative. I tried using Least squares fitting as described here The problem I have is the fact that the formula uses $\ln(y)$ which returns NaN for a negative value.

How do I get around this problem?

Can someone recommend a good source to read about this fitting approach?

In advance thank you for your help.

1

There are 1 best solutions below

0
On BEST ANSWER

If $y$ values are all negative, $-y$ values are all positive. Just handle the problem of $$-y=-A \exp(Bx)$$

$$\ln(-y) = Bx+\ln(-A)$$