ProgramTheSum

advertisement
ProgramYourOwnLeastSquares (DIY Least Squares)
The purpose of this problem is to show you what goes on behind the scenes when you
click “fit a line” in Origin, Excel, etc. It isn’t rocket science, but a simple computer
program.
Use a general purpose programming tool (Qbasic, QuickBasic, Visual Basic for Excel,
Fortran, C or even Matlab/Mathematica in line-by-line mode) to compute the coefficients
a and b (as in y = a + bx) in a linear least squares fit (earlier, you derived these
formulae). The program should prompt you to input the x,y data pairs.
Test your answer by feeding in some line data points. If you do not know how to
program at all, do not worry. We will give you lessons! See the TA or see me or go to
Books a Million (or similar) and pick up a copy of something like Beginning
Programming for Dummies, which will introduce you to Qbasic and other languages.
"Canned" software platforms like Matlab or Mathematica are limited compared to a
general purpose language, though they are often the faster choice….once you get past
their goofy syntax. For this problem, though, you have to use these packages without the
symbolic features—e.g., we want a line-by-line program.
The website also has links to computer resources:
http://macro.lsu.edu/CoreCourses/MSweb4/IntegratedTraining/IntegratedTraining.htm
(Look under VB Programming for the Chemical Engineering Department links).
Grading Criteria. For 80%, include this page as coversheet, a printout of the program
code, and the program on disk, CD-ROM or USB key with your name on it. For 20%
describe in a paragraph your prior experience with coding programs in general
purpose languages.
Download