the ordinary least squares technique how does linear regression workwell internallyit uses technique called ordinary least squaresit' also known asols you might see that term tossed around as well the way it works is it tries to minimize the squared error between each point and the linewhere the error is just the distance between each point and the line that you have sowe sum up all the squares of those errorswhich sounds lot like when we computed variancerightexcept that instead of relative to the meanit' relative to the line that we're defining we can measure the variance of the data points from that lineand by minimizing that variancewe can find the line that fits it the bestnow you'll never have to actually do this yourself the hard waybut if you did have to for some reasonor if you're just curious about what happens under the hoodi'll now describe the overall algorithm for you and how you would actually go about computing the slope and -intercept yourself the hard way if you need to one day it' really not that complicated remember the slope-intercept equation of lineit is =mx+ the slope just turns out to be the correlation between the two variables times the standard deviation in divided by the standard deviation in it might seem little bit weird that standard deviation just kind of creeps into the math naturally therebut remember correlation had standard deviation baked into it as wellso it' not too surprising that you have to reintroduce that term