Skip to main content
\( \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section3.1Finding a Trend Line

The following data were collected using a wooden yardstick as a cantilever. Six inches of the yardstick were secured to a desk. On the other end, a small plastic cup was tied to the 1-inch mark with a wire and an unbent paperclip was secured to make a pointer. A custom paper ruler was attached to the wall so that the zero aligned with the position of the paperclip when the cup was empty. Uniformly sized marbles were added to the cup and the subsequent position that the paperclip pointed to on the paper ruler were recorded.

Number of Marbles Displacement
0 0
5 0.9
10 1.8
15 2.65
20 3.5
25 4.4
30 5.3
35 6.2
40 7.1
50 8.9
60 10.8
70 12.7
80 14.7

This first demonstration finds a linear fit. Immediately after that, we do another demonstration of a proportional model which uses an intercept \(b=0\). After the code finds the fit, we also plot the data with the trend line. We work in steps, so you need to evaluate each step for later steps to work.

Start by loading the data for Sage to analyze. Sage works with data in terms of lists, which are entered using comma-separated values within brackets.

Next we define the type of model we analyze. In this case, we want a linear model \(d=am+b\), where \(d\) (displacement) is the dependent variable and \(m\) (number of marbles) is the independent variable.

Now that we see how Sage reports its results for the analysis, we want to extract the numbers from the equations. With those parameter values, we can have Sage report the best fit model as an equation.

Finally, we can have Sage create a graph showing two plots—the scatter plot of the data and the linear plot of the trend line.