Thursday, August 5, 2021

Linear Least-Squares Regression

Problem 14.9.


The concentration of E.coli bacteria in a swimming area is monitored after a storm:
The time is measured in hours following the end of the storm and the unit CFU is a "colony forming unit". Use this data to estimate (a) the concentration at the end of the storm (t = 0) and (b) the time at which the concentration will reach 200 CFU/100 mL. Note that your choice of model should be consistent with the fact that negative concentrations are impossible and that the bacteria concentration always decreases with time

Solution:


Based on the clues provided (underlined), we can expect the model best describes the given data should be exponential model.




The above equation can be linearized by taking its natural logarithm to yield:




Thus, a plot of ln c (y) versus t (x) will yield a straight line with a slope of β and an intercept of ln α.

The data can be set up in tabular form and the necessary sums computed as in table follow.










The mean can be computed as: 




The slope and intercept can then be calculated with Eq.(14.15) and (14.16) as in textbook:





Hence, the least-squares fit of transformed data is ln c = 7.5936 - 0.053506t.

The coefficients of the exponential model are determined as α = exp(7.5936) = 1985.44 and β = -0.053506. Thus, the least-squares exponential fit is c = 1985.44e-0.053506t. Using this exponential fit, we can solve for:

(a) When t = 0: c = 1985.44 CFU/100 mL
(b) When c = 200: t = 42.898 hours

Figure below showed the exponential model fit along with the data. 
*MATLAB commands to generate the plot:
>> t = [4 8 12 16 20 24];
>> c = [1600 1320 1000 890 650 560];
>> tp = linspace(min(t),max(t));
>> cp = 1985.44*exp(-0.053506*tp);
>> plot(t,c,'o',tp,cp),grid,xlabel('t (hr)'),ylabel('c (CPU/100 mL)')

No comments:

Post a Comment

Numerical Integration Formulas

Here are the M-files to implement composite trapezoidal rule for equally spaced data and unequally spaced data.  Composite Trapezoidal Rule ...