Year 11 Standard · Unit 5 Ready for the Diploma · Lesson 4 of 6

How do you decide which kind of curve to fit, and how good is the fit?

A table of data does not say which function made it. This lesson asks how to choose a family to try, how to fit it by hand so that a GDC can be checked, and how to measure how far a model sits from the data.

FunctionsGDC optional

Warm-up

Three quick ones from earlier work. Try each in your head or on paper before you open the answer.

  1. From Year 9: a line has gradient 2 and passes through (0, 5). Find y when x = 4.
    Answer13. 5 + 2 × 4.
  2. From Lesson 1: in y = 8 × 1.5x, what is y when x = 2?
    Answer18. 8 × 2.25.
  3. From Year 10: in y = x2 + 3x, find y when x = 4.
    Answer28. 16 + 12.
Words used in this lesson
first difference
a value minus the one before it. For example: the gaps in a column of y-values.
second difference
a difference of the first differences. For example: constant for a quadratic.
ratio
a value divided by the one before it. For example: constant for an exponential.
regression
finding the best-fitting function for data, usually with technology. For example: a GDC fit.
residual
the data value minus the model value. For example: above the line is positive.
extrapolation
using a model outside the range of the data. For example: predicting far ahead.

Visits to a website

A bookshop in Cape Town starts an advertising campaign and counts the visits to its website each day for the next few days: 40, 52, 68, 88, 112 and 141. A student says “it is going up by about 12 a day, so it is a line”.

Predict first: would a straight line, a curve that bends up, or something else fit better? What number would you work out from the table to decide? Use the first figure to see the check on four different data sets, then the second figure to see how a fit is judged.

1
straight linefamily that fits
3the constant value

Data set 1: y = 4, 7, 10, 13, 16, 19. The first differences are all 3, so a straight line fits.

Show me the steps
  1. Data set 1: the first differences are 3, 3, 3, 3, 3. They are constant, so the model is a straight line with gradient 3.
  2. Data set 2: the first differences are 3, 5, 7, 9, 11 and the second differences are all 2. A constant second difference means a quadratic, with a = 2 ÷ 2 = 1.
  3. Data set 3: the differences are 4, 6, 9, 13.5 and 20.25, not constant, but every ratio is 12 ÷ 8 = 1.5. A constant ratio means an exponential. Data set 4 has no constant row, so none of these three fits exactly.

Choose the family from the table, then fit it.

  • Equal steps in x (x goes up by 1 each row). If the first differences are constant, fit a line: the gradient is the difference.
  • If the second differences are constant, fit a quadratic y = ax2 + bx + c with a = (second difference) ÷ 2, when x goes up by 1 each row.
  • If the ratios are constant, fit an exponential y = a × bx with b = the ratio.
  • A residual is data value minus model value. A good fit has small residuals with no pattern.

A GDC finds the parameters quickly, but the table tells you which family to ask for.

1
0
39sum of the residuals
275sum of the squared residuals

Line y = 1x + 0: the residuals are 5, 4, 6, 7, 7, 10. Their sum is 39 and the sum of their squares is 275.

Show me the steps
  1. Line y = x: every residual is positive (5, 4, 6, 7, 7, 10), so the line is below every point. The squares add to 275.
  2. Set the gradient to 2 with c = 0: the residuals are 4, 2, 3, 3, 2, 4 and the squares add to 58. The line is still below every point, so raise c.
  3. Set c = 3: the residuals are 1, −1, 0, 0, −1, 1. They add to 0 and their squares add to 4, which is the smallest value any setting can give.

A good fit inside the data is not a promise outside it. A quadratic that fits six weeks of data may be negative at week 20; an exponential may grow past any real limit. Use the model for values between the data (interpolation) with care, and outside it (extrapolation) only with a reason. Also, residuals that add to zero do not show a good fit: look at the squares.

Worked examples

The visits are 40, 52, 68, 88, 112 for days x = 0, 1, 2, 3, 4. Choose a model, fit it by hand and predict day 7.

  1. The first differences are 12, 16, 20, 24, so they are not constant. The second differences are 4, 4, 4: a quadratic.
  2. a = 4 ÷ 2 = 2, and c = 40 (the value at x = 0). At x = 1: 2 + b + 40 = 52, so b = 10.
  3. The model is y = 2x2 + 10x + 40. Check x = 4: 32 + 40 + 40 = 112, which matches.
  4. At x = 7: 2 × 49 + 70 + 40 = 208 visits.

A GDC quadratic fit to the same data gives the same three numbers. The data at x = 5 is 141. What is the residual?

  1. The model at x = 5 is 2 × 25 + 50 + 40 = 140.
  2. Residual = data − model = 141 − 140 = 1, a small positive residual.

Your go. The first step is given. A table gives y = 10, 13, 18, 25 for x = 0, 1, 2, 3. Find a quadratic model by hand and use it to predict y at x = 6.

  1. The first differences are 3, 5, 7, so the second differences are 2, 2. Then a = 1.
  2. Find c and then b, and then put in x = 6.
Check the answer

c = 10 (the value at x = 0). At x = 1: 1 + b + 10 = 13, so b = 2. The model is y = x2 + 2x + 10, and at x = 6 it gives 36 + 12 + 10 = 58. A common slip is to use a = 2, the second difference itself.

With a GDC (optional)

Enter the x-values in one list and the y-values in another. Open the regression or curve-fit tool (often under a “stats” or “calc” menu), choose linear, quadratic or exponential, and read the parameters. Many GDCs also show a measure of fit; it helps you compare two models, but it does not tell you whether the model makes sense outside the data.

Different GDCs name the parameters slightly differently, so match them to the form y = a × bx or y = ax2 + bx + c on the screen. Fit by hand first and compare. Everything here can be done by hand.

Check before you go on

1. A table has y = 2, 6, 12, 20, 30 for x = 0, 1, 2, 3, 4. Which family of function fits it?

Your turn

Start at Level 1 and go as far as you can. Type negative numbers with a minus sign, for example -7. A wrong answer gets a reason, not just a cross: read it, then try again.

Level 1 · Getting started

2. A table gives y = 7, 12, 17, 22 for x = 0, 1, 2, 3, and the first differences are constant. A linear model predicts y at x = 10. What is it?

3. A quadratic y = ax2 + bx + c is fitted to values at x = 0, 1, 2, 3, and the second differences are all 10. What is a?

Level 2 · Building

4. A quadratic fits y = 4, 5, 10 at x = 0, 1, 2. Its second difference is 4, so a = 2 and c = 4. Find b in y = 2x2 + bx + 4.

5. A table gives y = 16, 24, 36, 54 for x = 0, 1, 2, 3. The ratios are constant. What does an exponential model predict at x = 5?

Level 3 · Stretch

6. A GDC fits the line y = 2.5x + 11 to some data. At x = 8 the data value is 27. What is the residual, data value minus model value?

7. Model P has residuals 2, −1, 3, −2 and Model Q has residuals 4, −4, 1, 0. What is the smaller of the two sums of squared residuals?

Something to think about

A line through the points leaves residuals that add to zero but are 5 on the left and −5 on the right. Another line leaves smaller residuals of the same sign. Which would you trust, and what would you look at?

One way to think about it

Look at the pattern of residuals, not only their size. Residuals that are positive on one side and negative on the other show a curve that the line misses. Residuals that are small and scattered with no pattern suggest the model is a fair description.

Exit ticket

8. A table gives y = 5, 10, 20, 40, 80 for x = 0, 1, 2, 3, 4. Which model should be fitted, and what does it predict at x = 6?