in Education by
I am currently using numpy.polyfit(x,y,deg) to fit a polynomial to experimental data. I would however like to fit a polynomial that uses weighting based on the errors of the points. I have found scipy.curve_fit which makes use of weights and I suppose I could just set the function, 'f', to the form a polynomial of my desired order, and put my weights in 'sigma', which should achieve my goal. I was wondering is there another, better way of doing this? Many Thanks. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For weighted polynomial fitting you can use: numpy.polynomial.polynomial.polyfit(x, y, deg, rcond=None, full=False, w=weights) see http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.polynomial.polyfit.html Important to note that in this function the weights should not be supplied as 1/variance (which is the usual form in many weighted applications), but as 1/sigma Although curve_fit and leastsq are much more general and powerful optimization tools than polyfit (in that they can fit just any function), polyfit has the advantage that it yields an (exact) analytical solution and is therefore probably much faster than iterative approximation methods like curve_fit and leastsq - especially in the case of fitting polynomials to multiple sets of y-data (obtained at the same x-vector) Update: As of numpy version 1.7, numpy.polyfit also takes weights as an input (which ideally should be supplied as 1/sigma, not 1/variance)

Related questions

0 votes
    Plots may also be adorned with error bars or tables. (a) True (b) False This question was posed to ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    Complete the sentence by choosing TWO WORDS either of which will fit the blank. The two words must both produce a ... on his bike. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    I have a barChart : that looks like this The bars align to the left of the category, for instance ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I am working with this data set: u...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have a 9-cell grid containing images (using bootstrap columns). The grid works fine and is responsive ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    If the ratio of the polynomial P (s) and its derivative gives a continued fraction expansion with ________ coefficients ... EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with poles at ω = 0, ω = ∞ must have ___________ term in the denominator polynomial. ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with poles at ω = 0, ω = ∞ must have excess ___________ term in the numerator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with zeros at ω = 0, ω = ∞ must have ___________ term in the numerator polynomial. ( ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with zeros at ω = 0, ω = ∞ must have an excess ___________ term in the denominator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with zero at ω = 0 and pole at ω = ∞ must have ___________ term in the numerator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with zero at ω = 0 and pole at ω = ∞ must have ___________ term in the numerator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with zero at ω = 0 and pole at ω = ∞ must have ___________ term in the denominator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    A driving point impedance with pole at ω = 0 and zero at ω = ∞ must have ___________ term in the denominator ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
...