I mostly use this forum to talk about mathematics with my students. If you’d like to see an actual such conversation that I had just a few weeks ago, you can check out this post.
Here’s a transcript of another such conversation that describes how to use a little bit of matrix algebra to help find the regression line of the form y=ax+b for the data
This particular solution uses the so-called normal equations so it involves a fair amount of matrix manipulation. For the purposes here, it shows that a Discourse topic with a fair bit of math renders pretty quickly and that the AMS macros are supported.
To solve the problem, at any rate, I guess we gotta solve X[a\:\:b]^{\mathsf{T}}\approx \mathbf{y}, where the first column of X is formed by the x-coordinates of the points, the second column of X is all ones, and \mathbf{y} is the vector whose entries are the y-coordinates of the points. That is:
To do so, we’ll solve the normal equations:
Well,
and
So, we’ve got to solve
Doing so yields
Thus, the regression line is y = \frac{2}{7} x + \frac{4}{7}.