data fitting - Python - trying to perform a more robust linear fit -
i have data fit linear function , fit determines other work (never mind, not important). i'm using numpy.polyfit
, , when include data , degree of fit, nothing else, produces plot:
now, fit okay, general consensus line of best fit being skewed red data points above , should fitting data below forms nice linear shape (beginning around congested blob of blue points). attempted add weighting call polyfit
, , chose arbitrary weighting of 1/sqrt(y-values), smaller y-values weighted towards more favourably. gave following:
which admittedly better i'm still unsatisfied, appears line low. ideally middle-ground, since chose arbitrary weighting, wondering if in general there way perform more robust fit using python, or if can done using polyfit
? using separate package if works fine too.
this question doesn't have programming or python , more statistics or linear algebra.
you try seeing error difference between best fit line or best fit quadratic see has less error. lot of context related.
if have 500 data points, find 500th order polynomial model dataset 0 error. if weight data points needs make sense data.
if want best fit line "look right" cut foreplay , draw want it. if want make sense ask mathematician formula makes sense follow it.
Comments
Post a Comment