CSCI 297 Assignment B
Selective and Repetitive Execution: Best-Fit Line
This assignment involves using FORTRAN to determine what is called the "best-fit line". This is an idea from statistics: we have a collection of points in the X-Y plane, and we want to know what line Y = M * X + B comes closest to going through all of the points. Usually no line is perfect, but we want the best one.
The algorithm for finding the best-fit line can be found here.
You may find that a good way to start on this is to read the algorithm and figure out what parts repeat, that is, what loops are needed. Decide what variables you need.
To calculate the best-fit line for one set of points requires a loop. We will have several such sets of points, so we wil need another loop as well.
What does the data look like?
Each line of data contains two floating-point numbers, the X and Y coordinates of a point.
Copy the data file into your directory. You can find it here.
The lines are actually organized into groups. In each group, there are lines representing points, and then there is a line containing -777.0 (twice) to mark the end of the group. This marker line does not represent a point. At the end of the whole file is a line containing -999.0 (twice). It is a delimiter which is there just to tell us when to stop.
Steps:
PRINT *
PRINT *
between groups of input values.
prog4 < data4.txt > output4.txt