# Curve Fitting 2

• Sep 14th 2010, 04:36 PM
Apprentice123
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?
• Sep 15th 2010, 02:54 AM
Ackbeet
Do you mean
Quote:

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.
• Sep 15th 2010, 03:16 AM
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?
• Sep 15th 2010, 05:33 AM
Apprentice123
Quote:

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 ?
• Sep 15th 2010, 05:53 AM
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.
• Sep 15th 2010, 06:09 AM
Apprentice123
Quote:

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.
• Sep 15th 2010, 06:17 AM
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.
• Sep 15th 2010, 06:32 AM
Apprentice123
Quote:

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
• Sep 15th 2010, 06:38 AM
Ackbeet
You're welcome. Have a good one!