Finding linear regression coefficients using F#
The following is an example problem that can be solved using linear regression.
For seven programs, the amount of disk I/O operations and processor times were measured and the results were captured in a list of tuples. Here is that list: (14,2), (16,5),(27,7) (42,9), (39, 10), (50,13), (83,20). The task for linear regression is to fit a model for these data points.
For this experiment, you will write the solution using F# from scratch, building each block one at a time.
Create a new F# program script in LINQPad as shown and highlighted in the following image:
Add the following variables to represent the data points:
Add the following code to find the values needed to calculate
b0
andb1
:Once you do this, you will get the following output:
The following is the final output we receive:
Now in order to understand how good your linear regression model fits the data, we need to plot the actual data points as scatter plots and the regression line as a straight...