CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Math / Functions You Can See

Fitting a Line to Data

Lesson 8 of 10 · 7 min · Free, no account needed

What you will learn

  • A model is a simple rule that describes messy data, like a line through a cloud.
  • A residual is a miss: the real value minus the line's prediction.
  • The best-fit line is the one with the smallest total miss. One bad point can drag it far.

Start the lesson

How the lesson goes

  1. 10 students: daily practice and typing speed. Can one line describe them?

    Draw your best line through the cloud. Press and drag.

  2. Now tune your line. Every miss shows as a stick.

    Drag the two handles. Get the average miss down to the green mark: 2.5 words a minute or less.

  3. Tap every student your line over-guesses.

    Over-guessing means the line says more than the student really types: the point sits under the line.

  4. Three words for fitting.

    A model is a simple rule that stands for messy data. This line is a model of typing speed.

    A residual is one miss: the real value minus the line's prediction. Each stick is a residual.

    The best-fit line has the smallest total miss. Here: about 1.5 more words a minute for each minute of practice.

  5. A typo sneaks into the data. The line jumps.

    The machine fits a line to every point, typos too. Find the bad point and tap it to remove it.

  6. Game: beat the machine.

    A new cloud each round. You get 10 seconds to place your line, then the machine draws its best one. Get within 10%.

  7. How could a computer find the best line by itself?

    Run both strategies for 20 moves. Then tap the one that ended with the smaller miss.

  8. Mia practices 16 minutes a day and types 6 words a minute faster than your line predicts.

    Drag Mia's point to where she really is.

  9. Speed round: does a line fit?

    Three clouds, 10 seconds each. Fling each one left if one straight line fits it, right if not.

Previous lesson: Stretch, Flip, Shift · Next lesson: Zoom In: Slope of a Curve · Part of the course: Functions You Can See

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab