Relation Between Length and Age The first model uses the von Bertalanffy

Relation between length and age the first model uses

This preview shows page 2 - 4 out of 11 pages.

Relation Between Length and Age The first model uses the von Bertalanffy equation , which upon solving the differential equa- tion yields the model: L ( t ; L * , b ) = L * 1 - e - bt . This is an equation giving the length of a fish, L , based on its age, t . It has two parameters that need to be fit to the data, L * and b . The reader is referred to the lecture notes: Linear Differential Equations for details on deriving the model, tables of the data, and a discussion of nonlinear least squares fitting of data. The data can be accessed through the MatLab file, fishdat.mat . The data on the length and age of Lake Trout, Salvelinus namaycush , in Lake Superior are copied from Kory Groetsch 1 and stored in MatLab variables tdfish for age and ldfish for length (vectors with 19 1 Kory Groetsch, Total Mercury and Copper Concentrations in Lake Trout and Whitefish Fillets, Activity: 19-23, From Lake Superior, Environmental Section, Biological Services Division, 1998
Image of page 2

Subscribe to view the full document.

elements). If we define these data points ( t i , L i ) , i = 1 .. 19, then the error between the measured length, L i , at time t i and the model evaluated at t i is e i = L i - L * 1 - e - bt i , i = 1 .. 19 . The Sum of Square Errors function satisfies J ( L * , b ) = 19 X i =1 ( L i - L ( t ; L * , b )) 2 = 19 X i =1 e 2 i , and has some scalar value for each pair of the parameter values, ( L * , b ), which we select as a vector in MatLab p = [( L * , b ]. With p we define a MatLab function for this sum of square errors function between the data and the model L ( t ; L * , b ) = L * 1 - e - bt = p (1) 1 - e - p (2) t . 1 function J = sumsq vonBert (p , tdata , ldata ) 2 % Function computing sum of square e r r o r s f o r von Bertalanffy model 3 model = p (1) * (1 - exp ( - p (2) * tdata ) ) ; 4 e r r o r = model - ldata ; 5 J = e r r o r * error ’ ; 6 end This function takes advantage of the vector capabilities of MatLab. The data are stored as vectors. Any of the internal functions, such as exp , with a vector argument produces a vector, and scalars are added and subtracted componentwise, i.e. , a - exp ([ x 1 , x 2 , ..., x n ]) = [ a - e x 1 , a - e x 2 , ..., a - e x n ] . In this function, error = [ e 1 , e 2 , ..., e n ] is a row vector, so error 0 , the transpose, is a column vector. The product error * error 0 is [ e 1 , e 2 , ..., e n ] e 1 e 2 . . . e n = e 2 1 + e 2 2 + ... + e 2 n , which is the sum of square errors. As noted above the age and length data are stored in tdfish and ldfish , respectively. The optimal solution is the nonlinear least squares fit to these data, which is the minimum possible value of the sum of square errors function over all possible L * and b . MatLab has a powerful function, which is capable of numerically finding the minimum of a function, fminsearch . You can learn about numerical algorithms for finding minima in Math 541 and details about this particular function with the MatLab help fminsearch command. For our problem, we need a reasonable initial guess, p 0 = [ L * 0 , b 0 ] = [100 , 0 . 1]. (A poor initial guess may prevent the algorithm from converging or require multiple iterations.) In addition, since our sum of square errors function requires input of the data, these must be supplied to the fminsearch in the OPTIONS part of this function (separated by []). Below we show how to execute the MatLab function
Image of page 3
Image of page 4
  • Fall '08
  • staff

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes