Question: Write a function polyfit file() which - receives as first input argument a file name as a string and as second a polynomial degree value,
Write a function polyfit file() which - receives as first input argument a file name as a string and as second a polynomial degree value, an integer, see description below.
- Read data from file, see below, and
- perform a polynomial fit to the given polynomial degree.
- Read data from file using the NumPy function loadtxt(). The test data will contain two-column floating point data, for x and y values. You do not have to set delimiter parameter to read data.
- Research and then use the NumPy function polyfit() for the fitting to the data.
- Return the array of fit coefficients which is the immediate outcome of the polyfit() function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
