# Thread: Curve Fitting 2

1. ## Curve Fitting 2

In a given experiment, measurements taken showed that the number of
elements of a bacterial population decreased with time, so
approximately exponential:

time - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 -8 - 9 - 10
amount - 419 - 274 - 181 - 122 - 85 - 61 - 46 - 36 - 30 - 26 - 24

Try adjusting the points above by a function of type:
$\phi (x) = a_1 e^{a_2 x}$

My solution:
I find z(x) = ln(x) (*ln of each amount*)
g1(x) = 1; g2(x) = x;

I find:
a11 = 11
a12=a21 = 55
a22 = 385
b1 = 47,4564
b2 = 205,1156

Matrix x Vector(beta1 and beta2) = Vector (b1 and b2)

a1 = expoent(beta1) = 322,37
a2 = beta2 = -0,2923

Is that right?

2. Do you mean
Try fitting the points above...
? Because, if so, I can think of at least two ways to solve this problem, one of them probably easier than the other.

3. You are writing variables without saying what they mean and leaving us to guess exactly what you are doing. Are you trying to do a "least squares" exponential fit? If so, what formulas are you using?

4. Originally Posted by HallsofIvy
You are writing variables without saying what they mean and leaving us to guess exactly what you are doing. Are you trying to do a "least squares" exponential fit? If so, what formulas are you using?
Sorry, I use fit by exponential functions

I need to find:
$a_1$ and $a_2$

I rode the table:
time - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 -8 - 9 - 10
amount - 419 - 274 - 181 - 122 - 85 - 61 - 46 - 36 - 30 - 26 - 24
ln(amount) - 6,0379 - 5,6131 - 5,1985 - 4,8040 - 4,4426 - 4,1109 - 3,8286 - 3,5835 - 3,4012 - 3,2581 - 3,1780

$g_1(x) = 1$;
$g_2(x) = x$;

I find:
$a_{11} = \sum_{k=1}^{11} g_1 (x_k) g_1(x_k) = \sum_{k=1}^{11} 1 = 11$

$a_{12} = a_{21} = \sum_{k=1}^{11} g_2 (x_k) g_1(x_k) = \sum_{k=1}^{11} x_k = 55$

$a_{22} = \sum_{k=1}^{11} g_2 (x_k) g_2(x_k) = \sum_{k=1}^{11} (x_k)^2 = 385$

$b_1 = \sum_{k=1}^{11} f(x_k) g_1(x_k) = \sum_{k=1}^{11} f(x_k) = 47,4564$

$b_2 = \sum_{k=1}^{11} f(x_k) g_2(x_k) = \sum_{k=1}^{11} f(x_k) x_k = 205,1156$

Matrix = (a11, a12, a21, a22) x Vector(Beta1, Beta2) = Vector(b1,b2)

$\beta_1 = 5,7757$
$\beta_2 = -0,2923$

$a_1 = e^{\beta_1} = 322,57$
$a_2 = \beta_2 = -0,2923$

It's correct ?

5. Your numbers are fine for a linear fit to the logarithm data. However, the plot of the logarithm of the data looks a lot more like a quadratic than a straight line. That is, you can write

$\ln(\phi(x))=\ln(a_{1})+a_{2}x=5.7763-0.2924x,$ with an $R^{2}$ value of $0.965.$ That's good, but not great. On the other hand, if you go with a quadratic fit to the logarithm data, that is, you assume

$\phi(x)=e^{ax^{2}+bx+c},$ then

$\ln(\phi(x))=ax^{2}+bx+c=0.0198 x^{2}-0.4905x+6.0734,$ with an $R^{2}$ value of $0.9995,$ which is an incredibly good fit.

Just a thought.

6. Originally Posted by Ackbeet
Your numbers are fine for a linear fit to the logarithm data. However, the plot of the logarithm of the data looks a lot more like a quadratic than a straight line. That is, you can write

$\ln(\phi(x))=\ln(a_{1})+a_{2}x=5.7763-0.2924x,$ with an $R^{2}$ value of $0.965.$ That's good, but not great. On the other hand, if you go with a quadratic fit to the logarithm data, that is, you assume

$\phi(x)=e^{ax^{2}+bx+c},$ then

$\ln(\phi(x))=ax^{2}+bx+c=0.0198 x^{2}-0.4905x+6.0734,$ with an $R^{2}$ value of $0.9995,$ which is an incredibly good fit.

Just a thought.
Thank you. I just knew the method of least squares.

7. The method of least squares can be applied to many more situations than just a linear fit, though that's probably the most common least squares. The fit I just described would be found using the same fundamental method.

8. Originally Posted by Ackbeet
The method of least squares can be applied to many more situations than just a linear fit, though that's probably the most common least squares. The fit I just described would be found using the same fundamental method.
Thanks

9. You're welcome. Have a good one!