Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions