understanding experimental data def gethorizontalspeed(abcminxmaxx)"""assumes minx and maxx are distances in inches returns horizontal speed in feet per second""inchesperfoot xmid (maxx minx)/ ypeak *xmid** *xmid *inchesperfoot #accel of gravity in inches/sec/sec ( *ypeak/ )** print 'horizontal speed ='int(xmid/( *inchesperfoot))'feet/secfigure computing the horizontal speed of projectile when the line gethorizontalspeed(abcdistances[- ]distances[ ]is inserted at the end of processtrajectoriesit prints horizontal speed feet/sec the sequence of steps we have just worked through follows common pattern we started by performing an experiment to get some data about the behavior of physical system we then used computation to find and evaluate the quality of model of the behavior of the system finallywe used some theory and analysis to design simple computation to derive an interesting consequence of the model fitting exponentially distributed data polyfit uses linear regression to find polynomial of given degree that is the best least-squares fit for some data it works well if the data can be directly approximated by polynomial but this is not always possible considerfor examplethe simple exponential growth function the code in figure fits th-degree polynomial to the first ten points and plots the results it uses the function call pylab arange( )which returns an array containing the integers - vals [for in range( )vals append( **ipylab plot(vals,'bo'label 'actual points'xvals pylab arange( , , , , pylab polyfit(xvalsvals yvals *(xvals** *(xvals** *(xvals** ) *xvals pylab plot(yvals'bx'label 'predicted points'markersize pylab title('fitting ** 'pylab legend(figure fitting polynomial curve to an exponential distribution