# Linear Algebra/Topic: Line of Best Fit/Solutions

## Solutions

Problem 1

Use least-squares to judge if the coin in this experiment is fair.

 flips 8 16 24 32 40 heads 4 9 13 17 20

As with the first example discussed above, we are trying to find a best $m$ to "solve" this system.

${\begin{array}{*{5}{rc}r}8m&=&4\\16m&=&9\\24m&=&13\\32m&=&17\\40m&=&20\end{array}}$ Projecting into the linear subspace gives this

${\frac {{\begin{pmatrix}4\\9\\13\\17\\20\end{pmatrix}}\cdot {\begin{pmatrix}8\\16\\24\\32\\40\end{pmatrix}}}{{\begin{pmatrix}8\\16\\24\\32\\40\end{pmatrix}}\cdot {\begin{pmatrix}8\\16\\24\\32\\40\end{pmatrix}}}}\cdot {\begin{pmatrix}8\\16\\24\\32\\40\end{pmatrix}}={\frac {1832}{3520}}\cdot {\begin{pmatrix}8\\16\\24\\32\\40\end{pmatrix}}$ so the slope of the line of best fit is approximately $0.52$ .

Problem 2

For the men's mile record, rather than give each of the many records and its exact date, we've "smoothed" the data somewhat by taking a periodic sample. Do the longer calculation and compare the conclusions.

With this input

$A={\begin{pmatrix}1&1852.71\\1&1858.88\\\vdots &\vdots \\1&1985.54\\1&1993.71\end{pmatrix}}\qquad b={\begin{pmatrix}292.0\\285.0\\\vdots \\226.32\\224.39\end{pmatrix}}$ (the dates have been rounded to months, e.g., for a September record, the decimal $.71\approx (8.5/12)$ was used), Maple responded with an intercept of $b=994.8276974$ and a slope of $m=-0.3871993827$ .

Problem 3

Find the line of best fit for the men's $1500$ meter run. How does the slope compare with that for the men's mile? (The distances are close; a mile is about $1609$ meters.)

With this input (the years are zeroed at $1900$ )

$A:={\begin{pmatrix}1&.38\\1&.54\\\vdots \vdots \\1&92.71\\1&95.54\end{pmatrix}}\qquad b={\begin{pmatrix}249.0\\246.2\\\vdots \\208.86\\207.37\end{pmatrix}}$ (the dates have been rounded to months, e.g., for a September record, the decimal $.71\approx (8.5/12)$ was used), Maple gives an intercept of $b=243.1590327$ and a slope of $m=-0.401647703$ . The slope given in the body of this Topic for the men's mile is quite close to this.

Problem 4
Find the line of best fit for the records for women's mile.

With this input (the years are zeroed at $1900$ )

$A={\begin{pmatrix}1&21.46\\1&32.63\\\vdots &\vdots \\1&89.54\\1&96.63\end{pmatrix}}\qquad b={\begin{pmatrix}373.2\\327.5\\\vdots \\255.61\\252.56\end{pmatrix}}$ (the dates have been rounded to months, e.g., for a September record, the decimal $.71\approx (8.5/12)$ was used), MAPLE gave an intercept of $b=378.7114894$ and a slope of $m=-1.445753225$ .

Problem 5

Do the lines of best fit for the men's and women's miles cross?

These are the equations of the lines for men's and women's mile (the vertical intercept term of the equation for the women's mile has been adjusted from the answer above, to zero it at the year $0$ , because that's how the men's mile equation was done).

${\begin{array}{rl}y&=994.8276974-0.3871993827x\\y&=3125.6426-1.445753225x\end{array}}$ Obviously the lines cross. A computer program is the easiest way to do the arithmetic: MuPAD gives $x=2012.949004$ and $y=215.4150856$ ($215$ seconds is $3$ minutes and $35$ seconds). Remark. Of course all of this projection is highly dubious — for one thing, the equation for the women is influenced by the quite slow early times — but it is nonetheless fun.

Problem 6

When the space shuttle Challenger exploded in 1986, one of the criticisms made of NASA's decision to launch was in the way the analysis of number of O-ring failures versus temperature was made (of course, O-ring failure caused the explosion). Four O-ring failures will cause the rocket to explode. NASA had data from 24 previous flights.

 temp °F 53 75 57 58 63 70 70 66 67 67 67 failures 3 2 1 1 1 1 1 0 0 0 0 temp °F 68 69 70 70 72 73 75 76 76 78 79 80 81 failures 0 0 0 0 0 0 0 0 0 0 0 0 0

The temperature that day was forecast to be $31^{\circ }{\text{F}}$ .

1. NASA based the decision to launch partially on a chart showing only the flights that had at least one O-ring failure. Find the line that best fits these seven flights. On the basis of this data, predict the number of O-ring failures when the temperature is $31$ , and when the number of failures will exceed four.
2. Find the line that best fits all 24 flights. On the basis of this extra data, predict the number of O-ring failures when the temperature is $31$ , and when the number of failures will exceed four.

Which do you think is the more accurate method of predicting? (An excellent discussion appears in (Dalal, Folkes & Hoadley 1989).)

1. A computer algebra system like MAPLE or MuPAD will give an intercept of $b=4259/1398\approx 3.239628$ and a slope of $m=-71/2796\approx -0.025393419$ Plugging $x=31$ into the equation yields a predicted number of O-ring failures of $y=2.45$ (rounded to two places). Plugging in $y=4$ and solving gives a temperature of $x=-29.94^{\circ }$ F.
2. On the basis of this information
$A={\begin{pmatrix}1&53\\1&75\\\vdots \\1&80\\1&81\end{pmatrix}}\qquad b={\begin{pmatrix}3\\2\\\vdots \\0\\0\end{pmatrix}}$ MAPLE gives the intercept $b=187/40=4.675$ and the slope $m=-73/1200\approx -0.060833$ . Here, plugging $x=31$ into the equation predicts $y=2.79$ O-ring failures (rounded to two places). Plugging in $y=4$ failures gives a temperature of $x=11^{\circ }$ F.
Problem 7

This table lists the average distance from the sun to each of the first seven planets, using earth's average as a unit.

 Mercury Venus Earth Mars Jupiter Saturn Uranus 0.39 0.72 1.00 1.52 5.20 9.54 19.2
1. Plot the number of the planet (Mercury is $1$ , etc.) versus the distance. Note that it does not look like a line, and so finding the line of best fit is not fruitful.
2. It does, however look like an exponential curve. Therefore, plot the number of the planet versus the logarithm of the distance. Does this look like a line?
3. The asteroid belt between Mars and Jupiter is thought to be what is left of a planet that broke apart. Renumber so that Jupiter is $6$ , Saturn is $7$ , and Uranus is $8$ , and plot against the log again. Does this look better?
4. Use least squares on that data to predict the location of Neptune.
5. Repeat to predict where Pluto is.
6. Is the formula accurate for Neptune and Pluto?

This method was used to help discover Neptune (although the second item is misleading about the history; actually, the discovery of Neptune in position $9$ prompted people to look for the "missing planet" in position $5$ ). See (Gardner 1970)

1. The plot is nonlinear.
2. Here is the plot.

There is perhaps a jog up between planet $4$ and planet $5$ .

3. This plot seems even more linear.
4. With this input
$A={\begin{pmatrix}1&1\\1&2\\1&3\\1&4\\1&6\\1&7\\1&8\end{pmatrix}}\qquad b={\begin{pmatrix}-0.40893539\\-0.1426675\\0\\0.18184359\\0.71600334\\0.97954837\\1.2833012\end{pmatrix}}$ MuPAD gives that the intercept is $b=-0.6780677466$ and the slope is $m=0.2372763818$ .
5. Plugging $x=9$ into the equation $y=-0.6780677466+0.2372763818x$ from the prior item gives that the log of the distance is $1.4574197$ , so the expected distance is $28.669472$ . The actual distance is about $30.003$ .
6. Plugging $x=10$ into the same equation gives that the log of the distance is $1.6946961$ , so the expected distance is $49.510362$ . The actual distance is about $39.503$ .
Problem 8

William Bennett has proposed an Index of Leading Cultural Indicators for the US (Bennett 1993). Among the statistics cited are the average daily hours spent watching TV, and the average combined SAT scores.

 1960 1965 1970 1975 1980 1985 1990 1992 TV 5:06 5:29 5:56 6:07 6:36 7:07 6:55 7:04 SAT 975 969 948 910 890 906 900 899

Suppose that a cause and effect relationship is proposed between the time spent watching TV and the decline in SAT scores (in this article, Mr. Bennett does not argue that there is a direct connection).

1. Find the line of best fit relating the independent variable of average daily TV hours to the dependent variable of SAT scores.
2. Find the most recent estimate of the average daily TV hours (Bennett's cites Neilsen Media Research as the source of these estimates). Estimate the associated SAT score. How close is your estimate to the actual average? (Warning: a change has been made recently in the SAT, so you should investigate whether some adjustment needs to be made to the reported average to make a valid comparison.)
1. With this input
$A={\begin{pmatrix}1&306\\1&329\\1&356\\1&367\\1&396\\1&427\\1&415\\1&424\end{pmatrix}}\qquad b={\begin{pmatrix}975\\969\\948\\910\\890\\906\\900\\899\end{pmatrix}}$ MAPLE gives the intercept $b=34009779/28796\approx 1181.0591$ and the slope $m=-19561/28796\approx -0.6793$ .