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 3: Fitting with more than one parameter (polynomial)
In the file polynomial_data.txt you can find 30000 measurements of the variable x between the range -1 and 1.
(a) Bin these measurements as a histogram with 20 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 least-squares method scipy.optimize.curve_fit to fit a polynomial of first, second, third and fourth degree to the histogram bins, taking the x-value to be the centre of each histogram bin and the y-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.curve_fit method.
(d) Use the optimal fitting parameters to calculate the 2ndf 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?
[
]
polynomial_data.txt

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 Databases Questions!