📘 CodingMarble Learn

Line of Best Fit

A line of best fit (trend line) is one straight line drawn through the middle of the dots on a scatter plot. About half the dots sit above it and half below, and the gaps are small. Its equation y = mx + c is a linear model: the slope m tells how much y changes for each 1 unit of x, and the intercept c is the value of y when x = 0. We use it to predict values we did not measure.

đŸŽŦ Step-by-step story

  1. Each dot is one student: hours studied (across) and test score (up). The dots go up together.
  2. Lay one straight ruler-line through the middle of the dots: about half above, half below.
  3. The orange sticks are the gaps from each dot to the line. A good line keeps them small and balanced.
  4. Read the line: it rises 6 marks for every 1 extra hour (slope). It starts at 40 marks at 0 hours (intercept).
  5. Use the line to predict: go up from 9 hours to the line, then across. About 94 marks.
  6. Free play: move the slope and intercept sliders and make the total gap as small as you can.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Does the line have to go through any dots?

No. It goes through the middle of the cloud. In step 1 the red line touches almost no dots but still shows the trend.

How do I know my line is good?

Count the dots above and below (roughly equal) and look at the gaps (small, not all on one side). The orange sticks in step 2 show this.

Why use points on the line and not data dots to find the slope?

The equation describes the line, so the points must lie on it. Data dots are a little above or below.

What does the intercept really mean?

It is the predicted y when x is 0, where the line meets the up axis. In step 3 it is 40 marks for 0 hours.

Can I predict for any x?

Only safely inside or close to the data range. In step 4 we predict 9 hours, just past 8. Much further is guesswork.

Is there only one correct line?

Drawn by eye, slightly different lines are fine. In free play you can see many lines give nearly the same small total gap.

What is a line of best fit?

A scatter plot shows pairs of numbers as dots. When the dots go up (or down) in a rough straight band, we say there is a linear association.

A line of best fit (also called a trend line) is one straight line that shows this trend. It does not have to pass through any dot. It just goes through the middle of the cloud.

How to draw a line of best fit by eye

  1. Look at the shape of the dots. Is it a straight band?
  2. Place a clear ruler along the band.
  3. Turn and slide it until about half the dots are above and half below.
  4. Check the gaps: they should be small, and not all big gaps on one side.
  5. Ignore an outlier (a dot far away from the rest) when you judge the line.

The gap from a dot to the line, measured straight up or down, shows how well the line fits. Small gaps = good fit.

The equation: slope and intercept meaning

Pick two points on your line (not data dots), for example (2, 52) and (7, 82).

Slope m = rise Ãˇ run = (82 − 52) Ãˇ (7 − 2) = 30 Ãˇ 5 = 6.

Intercept c: put one point in y = mx + c → 52 = 6 × 2 + c → c = 40.

So score ≈ 6 × hours + 40.

Always say the meaning with units: "marks per hour", "rupees per kg", "cm per year".

Making predictions (and their limits)

To predict, put the x value into the equation, or read up to the line and across.

A trend line shows things change together. It does not prove that one causes the other.

Key formulas and definitions

Worked examples

1. A scatter plot of age (years) and height (cm) of children goes up to the right. What kind of association is it?

Positive linear association: as age goes up, height tends to go up.

2. A trend line passes through (0, 20) and (5, 45). Find its equation.

m = (45 − 20) Ãˇ (5 − 0) = 25 Ãˇ 5 = 5. c = 20 (value at x = 0). Equation: y = 5x + 20.

3. For score = 6h + 40, predict the score for 3.5 hours.

score = 6 × 3.5 + 40 = 21 + 40 = 61 marks.

4. A line for phone battery is: charge % = −8t + 100, where t is hours of use. Explain slope and intercept.

Slope −8: battery drops about 8 % each hour. Intercept 100: at t = 0 the phone is fully charged (100 %).

5. Two students draw lines. Line A has 9 dots above and 1 below. Line B has 5 above and 5 below with small gaps. Which is better?

Line B. A good line of best fit splits the dots roughly evenly and keeps gaps small; line A is too low.

6. Using taxi fare = 15d + 50 (rupees, d in km), how far can you go for ₹230?

230 = 15d + 50 → 15d = 180 → d = 12 km.

Common mistakes

Practice quiz

1. A line of best fit should have:
2. In y = 4x + 10, the slope is:
3. In y = 4x + 10, what is y when x = 0?
4. A trend line going down to the right shows:
5. Predicting far outside the data range is called:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

How do you draw a line of best fit?

Place a ruler along the band of dots and adjust until about half are above and half below with small gaps. Draw one straight line; do not join dot to dot.

How do you find the equation of a line of best fit?

Choose two points on your line, find slope = rise Ãˇ run, then find the intercept with c = y − mx. Write y = mx + c.

What is the difference between a line of best fit and linear regression?

A line of best fit can be drawn by eye. Linear regression uses a formula (least squares) to find the exact best line.

Where this is taught

USA (Common Core, NGSS, AP)Grade 8Statistics and Probability (8.SP)

Learn first

Learn next

Related lessons

All Maths lessons