the call pylab polyfit(observedxvalsobservedyvalsnfinds the coefficients of polynomial of degree that provides best leastsquares fit for the set of points defined by the arrays observedxvals and observedyvals for examplethe call pylab polyfit(observedxvalsobservedyvals will find line described by the polynomial ax bwhere is the slope of the line and the -intercept in this casethe call returns an array with two floating point values similarlya parabola is described by the quadratic equation ax bx thereforethe call pylab polyfit(observedxvalsobservedyvals returns an array with three floating point values the algorithm used by polyfit is called linear regression this may seem bit confusingsince we can use it to fit curves other than lines the method is linear in the sense that the value of the dependent variable is linear function of the independent variables and the coefficients found by the regression for examplewhen we fit quadraticwe get model of the form ax bx in such modelthe value of the dependent variable is linear in the independent variables and and the coefficients aband the function fitdata in figure extends the plotdata function in figure by adding line that represents the best fit for the data it uses polyfit to find the coefficients and band then uses those coefficients to generate the predicted spring displacement for each force notice that there is an asymmetry in the way forces and distance are treated the values in forces (which are derived from the mass suspended from the springare treated as independentand used to produce the values in the dependent variable predicteddistances ( prediction of the displacements produced by suspending the massthe function also computes the spring constantk the slope of the lineais distance/force the spring constanton the other handis force/distance consequently is the inverse of function is linear if the variables appear only in the first degreeare multiplied by constantsand are combined by addition and subtraction