Question: Polynomial Fitting [ 4 2 points ] - Can I please get assistance with the code I want to see how this is supposed to

Polynomial Fitting [42 points]- Can I please get assistance with the code I want to see how this is supposed to look if it is block codes or a whole code?
In this problem, we write a program to estimate the parameters for an unknown polynomial using the polyfit() function of the numpy package.
1)
Please plot the noisy data and the polynomial you found (in the same figure). You can use any value of m selected from 2,3,4,5,6.
2)
Plot MSE versus order m, for m =1,2,3,4,5,6,7,8 respectively. Identify the best choice of m.
3)
Change variable noise_scale to 200,300,400,600,800,1000 respectively, re-run the algorithm and plot the polynomials with the m found in 2). Discuss the impact of noise scale to the accuracy of the returned parameters. [You need to plot a figure like in 1) for EACH choice of noise_scale.]
4)
Change variable number_of_samples to 40,30,20,10 respectively, re-ran the algorithm and plot the polynomials with the m found in 2). Discuss the impact of the number of samples to the accuracy of the returned parameters. [You need to plot a figure like in 1) for EACH choice of number_of_samples.]
Please use the following code at the beginning of your program to generate the data.
Simulated data is given as follows in Python:
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
noise_scale =100
number_of_samples =50
x =30*(np.random.rand(number_of_samples, 1)-0.5)
y =5* x +15* x**2+2* x**3+ noise_scale*np.random.randn(number_of_samples, 1)
plt.plot(x,y,'ro')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!