Starting from:

$30

CSE218 Curve Fitting-Solved

you are required to fit a number of curves on a given input data. The data will be input from a file named “data.txt”. There will be an arbitrary number of lines in the file. Each line will contain two double values separated by a space. These two values together will form a point in (x,y) form. A sample input file is provided for your convenience. You are required to do the following tasks: 1. Plot the points on a graph.

2. Fit a first-order curve and plot it on the graph. Print values of relevant parameters for the curve and the corresponding value of correlation coefficient (​r​).  

3. Fit a second-order curve and plot it on the graph. Print values of relevant parameters for the curve and the corresponding value of correlation coefficient (r​ ).​  

4.Fit a third-order curve and plot it on the graph. Print values of relevant parameters for the curve and the corresponding value of correlation coefficient (​r​).  

Special Notes: 

1.  Your code must be in Python3. You cannot use any library other than numpy and matplotlib. Please note that you are not allowed to use any library function (not even from numpy) for performing regression.

2.  Plot all the curves and points in a single graph. Use appropriate scale, labels, legends, etc.

3.  Printing values of parameters and coefficients should be to console or file, not on the graph.

3. The data.txt file provided to you is just a sample. Your code may be tested with a different data file with the same format.

More products