Question: I need a python script Exercise 3 : Fitting with more than one parameter ( polynomial ) In the file polynomial _ data.txt you can
I need a python script
Exercise : Fitting with more than one parameter polynomial
In the file polynomialdata.txt you can find measurements of the variable between the range and
a Bin these measurements as a histogram with bins and calculate the uncertainty on the number of measurements in each bin using the Poisson distribution. Plot this histogram with error bars.
b Use the leastsquares method scipy.optimize.curvefit to fit a polynomial of first, second, third and fourth degree to the histogram bins, taking the value to be the centre of each histogram bin and the value to be the number of measurements. Plot the resulting polynomial fits overlaid on the histogram.
c For each fit, calculate the uncertainties on the parameters using the covariance matrix returned by the scipy.optimize.curvefit method.
d Use the optimal fitting parameters to calculate the for the different fits and plot it as a function of the degrees of the polynomial.
e What do you think was the degree of the polynomial used to generate the data?
polynomialdata.txt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
