If Y depends on X, we have ordinary 2D regression line.
But if Y depends on m variables X1,X2,...,Xm then we need to find
m values of b to accompany all Xi. Formally speaking
Matrix form of the equation
We define 2 matrices
Then we can rewrite Y with X and B as:
Generalized matrix form
Now we want to generalize the experiment, instead of 1 observation, we want to do n observations.
We would have n variables y1,y2,y3,...,yn
First, we have equation form
Then, the matrix form
Find the matrix B
- MT is the transpose matrix of M
- M−1 is the inverse matrix of M (M−1⋅M=I)
Hackerrank has an exercise for you to test your knowledge:
You have finished
10 days of statistics challenge. I have learned a lot and so did you.
I hope it benefits you as much as it does to me.
Thanks Hackerrank for the challenges and inspirations.