This tutorial is a quick review of linear algebra. The reason we're reviewing linear algebra is because the best-fit line uses this algebra. It uses the algebra that describes a line. So in order to find the line of best-fit, we need to have some understanding of linear algebra. Another tutorial will go through the line of best-fit. This is just the review.
Now, when you're graphing and making a scatterplot, if you swap the explanatory and the response variable, you change which one goes in the x and y-axis, that's not going to change the correlation. But it is very much going to change the look of the best-fit line. So you just need to pick a way and use that one if there's no clear explanatory in response.
And then the key fact about linear algebra is you have an equation. You might have seen it before as this y equals mx plus b. Often in statistics, we change the right side around a little bit and say y equals b0 plus b1 times x. So these parts are the same. This b matches up with b0. And this m matches up with this b1.
With both of these equations, they're telling us the same thing. They're telling us that you find y by multiplying the value by the slope and then adding on the intercept. So here, the intercept is b. Here the intercept is b0. That's what you're adding on. Here, the slope is m. Here the slope is b1. That's what you're multiplying the value by.
Now, as another part of our review, the slope is essentially the rate of change of the line. So it's telling you how much y changes when x increases by one unit. And then the y can increase or decrease there. The intercept, on the other hand, is telling us where the line is intersecting the y-axis, so giving us the value for y when x is 0.
If we have an equation of a line, we can use that equation to find some coordinate pairs, to find some x's with some y's. I'll show you how to do that. We have our equation here y equals 2x plus 5. I like to set up a chart to kind of help me remember where all my pieces are.
So x's are what I'm picking as my input. And then I'm inputting them into the equation to get out the y-values. So you can pick whatever variable or values you want for x. I like to pick some negative, some positive just to make sure I get a good range. So I'm going to say negative 2, 0, 1, and 3.
Now, in this middle part, it's kind of like my scrap work area. So I'm going to say negative 2 times 2, so the x-value times the slope. And then add on the intercept. So 2 times negative 2 is negative 4 plus 5 gives me a y of 1. Here, 0 goes in for x, so 2 times 0 plus the intercept of 5 gives me 5. Here, the 1 goes in for x 2 times 1 plus the intercept is 5, so 2 plus 5, 7. Here, the 3 is going for x. So 2 times 3 plus 5. 6 plus 5, 11.
So when you are trying to find your xy pairs, you start by inputting an x-value to your formula to get out a y-value. Now, if you wanted to, you could work backwards essentially. If you had a y-value, you could figure out what x-values paired with it. So I'm going to make a little bit of room on my chart here to show that.
So for example, if we knew that y was 10, in order to find out what the x was, we need to work backwards. So you can write 10 equals 2x plus 5. Because I know that whatever x value I put in, I multiplied by 2 and added 5 to get 10. So I need to go backwards so I'm going to take away 5. So I'm going to take away 5, take away 5, and I get that 5 is 2x.
So now, I know that whatever my x-value was, I had multiplied it by 2 first. So now, I need to divide by 2 and divide by 2. So I know that x was 5 divided by 2, 2.5.
Now, if I want to double check my work, I can work forwards again. I can say 2.5 times 2 plus 5. And I do, in fact, get 10. So I know I did it right.
There's one more thing I want to show. So for this example, let's zoom in a little bit to focus on the calculations. This example asks us to write the equation of a line for iPads where x is the number of gigabytes and y is the cost. So they're asking us for that equation.
And there's a couple of different forms that we can write this in. Typically, we're going to use standard form or something called point slope. I personally like to use the slope intercept. And that's the y equals mx plus b.
So in order to find our form here for our equation, I need the m. I need the slope. And I need the b, the y-intercept. So in order to find slope, that's the change in the y's divided by the change in the x's. And here, they tell us y is the cost.
So a 16 gigabyte model costs for $499. And a 64 gigabyte model cost $699. So the change in there is the difference between these two. So the $699 minus the $499, which gives us that $200. And then the change in the x, for that we need to find out the change in the number of gigabytes. So from the 64 down to the 16, we do 64 minus 16, and get 48. Now, when you do 200 divided by 48, you get a number that's fairly long, but we're going round to 4.167.
Now, with our slope, and this is rounded so everything is going to be a little bit off from here, you could leave it as the fraction if you wanted to be exact. We're going to use that to find out our b or y-intercept. So we know that y equals instead of the m, I know my slope now is 4.167 times x plus b.
Now, in order to find b, I need to insert a y and an x. Now, here is one x and a y pair, or down here is another x and a y pair. Doesn't matter which one you choose because you're forming a straight line that's going through both those points. Either one will work.
I'm going to choose to use this xy pair. So we're going to say 699 equals 4.167 times 64 plus b. Now, once we do that 4.167 times 64, we get 267 about. So we have 699 equals 267 plus b. To get the b by itself, we're going to subtract 267 from both sides. And then we get our result of 432 equals b.
So we have our slope. We have our m right here. And we have the b down here. So I'm going to combine those two pieces together in my equation. So we're going to have y equals 4.167x plus 432. So we've rounded a bit, so this isn't perfect, but it's giving us the equation of a line for the cost of an iPad based on the number of gigabytes.
This has been your linear algebra review. I know it's a lot of information compacted tightly into one spot, but it's a good review in order for finding lines of best-fit.