Pre-Algebra • Statistics & Probability

Fitting Lines to Data — I can fit a line to data informally and interpret slope and intercept in context.

Learn how to draw a line through scattered data points and explain what the slope and intercept really mean.

Middle School Math emblem with sigma notation, geometric shapes, and a ruler.
Inside this lesson 10 sections 5 questions 8 figures

SECTION 1

Where Did This Idea Come From?

People have been collecting data for thousands of years. Farmers tracked rainfall. Traders recorded prices. But for a long time, nobody had a good way to see patterns hiding inside all those numbers.

Drawing a line through data points is one of the simplest and most powerful tools in all of math and science. It lets you summarize messy, real-world information with a single straight line. That line can then help you make predictions about things you haven't measured yet.

1600s • Early Data Tables

Scientists like Galileo began recording measurements in organized tables, looking for relationships between variables like distance and time.

1686 • First Scatter Plot

Edmund Halley (the comet guy!) created one of the earliest scatter plots by graphing air pressure against altitude.

1805 • Least Squares Method

Adrien-Marie Legendre published a mathematical method for finding the "best" line through data. This idea is still used today in every field of science.

Today • Lines of Fit Everywhere

From weather forecasts to sports stats, fitting lines to data is one of the most common tools in the modern world.

The big question this lesson answers is: How do you draw a reasonable line through a cloud of data points, and what does that line actually tell you?

SECTION 2

Core Ideas You Need to Know

Before you start drawing lines, let's make sure you understand a few key ideas. These are the building blocks for the whole lesson.

1

Scatter Plot

A graph where each data point is shown as a dot. The x-axis shows one variable, and the y-axis shows another. You use it to spot patterns.
2

Line of Fit

A straight line drawn through a scatter plot that follows the general trend of the data. It doesn't have to pass through every single point.
3

Slope

How steep the line is. It tells you how much y changes each time x increases by 1. Think of it as the "rate of change."
4

Y-Intercept

The point where the line crosses the y-axis (where x = 0). It often represents a starting value before anything changes.
5

Trend

The overall direction of the data. A positive trend goes upward from left to right. A negative trend goes downward. No trend means the dots look random.
✦

KEY TAKEAWAY

Think of a line of fit like drawing a path through a messy room. You can't step on every single toy, but you find the path that gets closest to most of them. The line doesn't need to touch every data point—it just needs to follow the general direction of the data.

SECTION 3

Seeing the Line in a Scatter Plot

The best way to understand a line of fit is to see one in action. Below is a scatter plot that shows how many hours students studied and the test scores they earned. Notice how the dots roughly follow an upward pattern.

Study Hours vs. Test ScoreHours StudiedTest Score0123455060708090Line of Fitdata points
Each cyan dot is one student's data. The dashed pink line is the line of fit—it follows the overall upward trend without touching every point.

Look at the diagram above. The dots are not in a perfect line. Some are a little above the pink line, and some are a little below it. That's totally normal! Real data is messy. The line of fit just captures the overall direction the data is heading.

💡

How to Draw a Line of Fit by Hand

Use a ruler or the edge of a piece of paper. Try to have roughly the same number of points above your line as below it. The line should run through the "middle" of the cloud of dots.

SECTION 4

The Equation Behind the Line

Every straight line can be described by a simple equation. Once you know this equation, you can plug in any x-value and predict the matching y-value.

SLOPE-INTERCEPT FORM

y=mx+by = mx + b

y = the output (what you predict) • m = slope (rate of change) • x = the input • b = y-intercept (starting value)

SLOPE FORMULA

m=(y2−y1)÷(x2−x1)m = (y₂ − y₁) ÷ (x₂ − x₁)

Pick two points on your line (not data points—points on the line). Subtract the y-values, then subtract the x-values. Divide.

The slope tells you the speed of change. In our study-hours example, a slope of 8 would mean that for every extra hour a student studies, their test score goes up by about 8 points.

The y-intercept tells you the starting point. If b = 55, that means a student who studies 0 hours would score about 55 on the test. It's the score you "start with" before studying kicks in.

📝

Does the y-intercept always make sense?

Not always! Imagine a line that predicts a person's height based on their age. The y-intercept would be the height at age 0—a newborn. That might be reasonable. But sometimes the y-intercept gives a silly answer. Always check if x = 0 makes sense in your real-world situation.

SECTION 5

What Slope and Intercept Look Like

Slope and intercept aren't just numbers—they tell a story. Let's see what different slopes look like on a graph and what they mean in real life.

Comparing Different SlopesPositive SlopeAs x increases, y increasesm = +3Negative SlopeAs x increases, y decreasesm = −2Zero Slopex changes, y stays the samem = 0
A positive slope means the line goes up. A negative slope means the line goes down. A zero slope means the line is flat—no change at all.
Real-World ExampleSlope MeaningY-Intercept Meaning
Hours studied → Test scorePoints gained per extra hourScore with zero hours of study
Age of a car → Value in dollarsDollars lost per year (negative!)The price when the car was brand new
Minutes exercising → Calories burnedCalories burned per minuteCalories burned at rest (before exercising)

Interpreting slope and y-intercept in everyday situations

SECTION 6

Step-by-Step: Fitting a Line and Interpreting It

A lemonade stand owner tracked the temperature outside and how many cups of lemonade she sold. Here is her data:

Temperature (°F)Cups Sold
6010
7018
7520
8025
9035
9538

Lemonade Stand: Fitting a Line

  1. 1

    Step 1 — Plot the Points

    Put temperature on the x-axis and cups sold on the y-axis. Plot each pair as a dot on graph paper or a coordinate plane.
  2. 2

    Step 2 — Draw a Line of Fit

    Use a ruler to draw a straight line through the middle of the dots. Try to have about the same number of points above and below the line. Our line passes close to the points (60, 10) and (90, 34).
  3. 3

    Step 3 — Find the Slope

    Pick two points on the line (not necessarily data points). We'll use (60, 10) and (90, 34). Slope = (34 − 10) ÷ (90 − 60) = 24 ÷ 30 = 0.8
    m = 0.8 cups per degree
  4. 4

    Step 4 — Find the Y-Intercept

    Use the slope and one point in y = mx + b. Plug in (60, 10): 10 = 0.8 × 60 + b → 10 = 48 + b → b = 10 − 48 = −38.
    b = −38
  5. 5

    Step 5 — Write the Equation

    Our line of fit is y = 0.8x − 38.
    y = 0.8x − 38
  6. 6

    Step 6 — Interpret in Context

    Slope: For every 1°F increase in temperature, the stand sells about 0.8 more cups of lemonade. Y-intercept: At 0°F, the model predicts −38 cups, which doesn't make sense. This tells us the model only works for temperatures near the data we collected.

SECTION 7

When Lines of Fit Work—and When They Don't

A line of fit is an awesome tool, but it isn't magic. Let's compare what it does well and where it falls short.

Strengths ✅Limitations ⚠️
Quick to draw—you only need a rulerDifferent people may draw slightly different lines
Good for making predictions within the data rangePredictions far outside the data range can be wild (like −38 cups!)
Easy to interpret slope and intercept in contextOnly works when the data actually follows a straight-line pattern
Summarizes a lot of data with one equationIt ignores outliers (unusual data points) that might matter

Strengths vs. Limitations of informal line fitting

💡

KEEP THIS IN MIND

A line of fit is like a weather forecast—it gives you a good estimate, not a guarantee. It works best when you stay close to the data you actually have. Making predictions way outside that range is called extrapolation, and it can lead to silly answers.

SECTION 8

From Informal Lines to Formal Methods

You just learned how to fit a line informally—by eyeballing it with a ruler. In later math courses, you'll learn a formula that finds the absolute best line through the data. Here's a quick preview.

FeatureInformal Line of Fit (This Lesson)Least-Squares Regression (Future Course)
How you draw itBy eye, using a rulerCalculated with a formula or computer
AccuracyGood estimateMathematically the best possible line
Everyone gets the same answer?No—lines will vary slightlyYes—the formula gives one answer
Tools neededPencil and rulerCalculator or software

Informal vs. formal line fitting

The skills you're building right now—understanding slope, intercept, and trend—are the foundation for all of that future work. You're learning the thinking; the formulas come later.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

A scatter plot shows the number of hours a student sleeps and the number of yawns they make during class. The line of fit has a negative slope. In your own words, what does the negative slope mean in this situation?
Show answer
A negative slope means that as the number of hours of sleep increases, the number of yawns during class decreases. In other words, students who sleep more tend to yawn less. Each extra hour of sleep is associated with fewer yawns. The line goes downhill from left to right on the graph.

Question 2: BASIC CALCULATION

A line of fit passes through the points (2, 14) and (6, 30). Find the slope of the line. What does the slope mean if x is weeks of practice and y is the number of free throws made out of 50?
Show answer
Slope = (30 − 14) ÷ (6 − 2) = 16 ÷ 4 = 4. The slope is 4. In context, this means that for every additional week of practice, the player makes about 4 more free throws out of 50 attempts. The positive slope tells us practice is paying off!

Question 3: INTERMEDIATE

A line of fit for data about the age of a phone (in years) and its resale value (in dollars) is y = −50x + 400. Find the predicted resale value of a phone that is 3 years old. Then explain what the slope and y-intercept mean.
Show answer
Plug in x = 3: y = −50(3) + 400 = −150 + 400 = 250 dollars. The slope of −50 means the phone loses about $50 in value each year. The y-intercept of 400 means the phone was worth about $400 when it was brand new (age = 0 years). After 3 years, the model predicts the phone is worth $250.

Question 4: APPLIED

A farmer recorded the rainfall (in inches) and crop yield (in bushels per acre) over several years. Her line of fit is y = 12x + 20. How many bushels per acre does the model predict when rainfall is 5 inches? If the highest rainfall in her data was 8 inches, would you trust a prediction for 20 inches of rain? Explain.
Show answer
At x = 5: y = 12(5) + 20 = 60 + 20 = 80 bushels per acre. For 20 inches: y = 12(20) + 20 = 260 bushels per acre. You should not trust the prediction for 20 inches because 20 is far outside the data range (the most she measured was 8 inches). This is called extrapolation, and the relationship might not stay linear at extreme rainfall levels—too much rain could actually flood and damage crops.

Question 5: CRITICAL THINKING

Two students each draw a line of fit for the same scatter plot. Student A's line is y = 3x + 5. Student B's line is y = 2.5x + 7. Both lines look reasonable. Can both be correct? Why might their lines be different, and how would you decide which is better?
Show answer
Both lines can be acceptable because fitting a line informally is based on judgment—there is no single "right" answer when you draw by hand. Their lines differ because each student positioned the ruler slightly differently. To decide which is better, you could check which line has data points more evenly split above and below it, or you could calculate how far each data point is from each line and see which line has smaller total distances. In later courses, students learn a formula (least-squares regression) that removes this guessing and gives one exact answer.

SUMMARY

Lesson Summary

Summary

A scatter plot shows the relationship between two variables as a cloud of dots. When the dots follow a roughly straight pattern, you can draw a line of fit through the middle of them. This line is described by the equation y = mx + b, where m (the slope) tells you the rate of change—how much y changes for each 1-unit increase in x—and b (the y-intercept) tells you the starting value when x equals zero.

Always interpret slope and intercept in context—use the real-world units from the problem. A positive slope means the line rises, a negative slope means it falls, and a slope of zero means no change. Remember, your line is an estimate—predictions are most trustworthy within the range of your original data.

Varsity Tutors • Pre-Algebra • Fitting Lines to Data