Fitting a line to data using a graphing calculator (IMRA 2026 publisher-initiated change)
About this video
Using Owen's weekly walking distances, the video enters the data into a Desmos table and fits a line with the regression y1 ~ a x1 + b, getting a = 1.375 and b = 2.446. Rounded to the nearest tenth the model is y = 1.4x + 2.4, which predicts 16.4 km in week 10 (16.2 km with the unrounded model).
You'll be able to
- use a graphing calculator such as Desmos to fit a line to real-world data.
- write the fitted line in slope-intercept form, rounding values as instructed.
- interpret the slope and y-intercept of a line of best fit in context.
- use a linear model to make a prediction and explain why rounding changes it.
Key words
- linear regression
- A method for finding the line that best fits a set of data points that don't all lie on one line.
- slope-intercept form
- A line written as y = ax + b (or y = mx + b), where a is the slope and b is the y-intercept.
- model
- An equation that describes a real-world relationship, used to estimate or predict values.
- y-intercept
- The value the model gives when x = 0.
- approximately equal (~)
- In Desmos, the squiggly symbol tells it to find the values that fit the data as closely as possible, not exactly.
Transcript
- [Instructor] We're told that Owen tracks the total distance he walks each week as he tries to increase his weekly distance over time. So this is the weeks since he started tracking, looks like in the first week he walked three kilometers and then a week after that, four and a half and so on and so forth.
Now they're saying create a linear function in slope intercept form that models the relationship between x and y. Round each value in the function to the nearest tenth and then use that model to predict the distance Owen will walk in week 10. Okay, so I'm going to use Desmos to do this because as you can see, you have multiple points here and this is real world data.
So it's unlikely that they sit exactly on the same line. So instead of just taking two points and trying to figure out the slope and intercept that the line that would go just between those two points, we're actually going to use Desmos in order to try to fit a line to this data.
So let me get my Desmos calculator. So let me get my Desmos calculator here. And what I am going to do before I graph it, let me make sure I can see the data here, is I'm going to insert an item. I'm going to insert a table. Let's see. All the x coordinates will go from 0 to 6.
So 0, 1, 2, 3, 4, 5 and 6. I hope you can see that. Let me see if I can make my font size a little bit bigger. There you go. That's a little bit easier to see now. Make it one more big. There you go. All right. And then the data here is 3, 4.5, 4, 7, 6.5, 9 and 12.
All right. Now what's interesting here is if I now, since I already typed in the data, I can now look at the broader graph here, is I can see my data is actually plotted here. So this is the point 0, 3. This is the point 1, 4.5. You can see that there if I actually click on the points.
Actually, why don't I? I might leave that there. That's interesting. Okay, so the next thing is I actually want to create a model. That's what they asked me to do. They said create a linear function in slope intercept form that models the relationship between x and y.
So the way that I'm going to do this in Desmos right now is I am going to, and this is a little bit of a, go to this next line right over here. Make sure you can see what I'm seeing. So line two. And I'm going to say, okay, I'm going to try to fit a line. I'm going to do y, and it's going to give a subscript one.
And then because we know we're not going to exactly fit all of this data, we're going to approximately fit all this data, we will use this little squiggly. So let me make sure I don't do that as a subscript. So then that little squiggly right over there. So one way to think about it is that that's going to be approximately equal to.
And we're going to use a times x sub 1 x sub 1. And this data up here is x sub 1 right over there. And we're going to say y1, y1 is approximately equal to a times x sub 1. It's going to try to estimate what a is. And then I'm going to give it another parameter right over here plus b.
And so there you have it. It actually tried to fit a linear equation or it tried to fit a line to that. It seems like it did a pretty good job. And it got a is going to be 1.375 and b is 2.44. So I can... Actually, let me just type those in. And they wanted us to round those values.
So let me do that. So let me write this over here. I'm going to get y is equal to, we have to round to the nearest tenth, 1.4 x plus, and if we round 2.446 to the nearest tenth, it's going to be 2.4. Now use the model to predict the distance Owen will walk during week.
Actually, before I even do part two, let's just think about what this means. And actually let me give the graph back here because it's easier to see visually. This means one way to interpret this, if the slope is 1.375 or 1.4 is what I rounded it to, that on a given week, he's roughly increasing the amount he walks by 1.4, 1.375.
Is that in kilometers? Yes, kilometers. Another way to think about this, what's the y intercept mean, what is this 2.44? Well, according to this linear estimate, this linear regression, it would say in week, in that first week, right at the beginning of his experiment or whatever he's trying to measure, that he would have walked that far.
Now we know that the actual data was a little bit higher than that. It was he walked three kilometers. But once again, this regression is kind of trying to estimate the point. So it's underestimating that first point, but it's overestimating some of the other ones.
Now, if we want to figure out how far he's going in week 10, that's part two of that question, we could do it two ways. You could go straight into Desmos here and look at week 10. So that'd be the 0.10 comma something. So let's see, that would be right over there.
And by that estimate it would be 16.2 kilometers. Now the other way we could do it is use this little rougher model where I already rounded. And this is all going to be approximation. It's all estimation. So if we say y, this is what our model would predict. 1.4 times 10, week 10, plus 2.4.
This is going to be 14 plus 2.4, which is going to be equal to 16.4 kilometers. So it depends which way you do it. If you used the original model we just had, right over here, you got a slightly different answer because here we did not round, we did not round our values.
So here, whoops, here at 10, we got 16.19 versus here at 10, we got 16.4 kilometers because we rounded these values the way they told us to.
Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.