'Vectorized form Derivation of Multiple Linear Regression Cost Function

Can some one with expertise explain how the following vectorized format of multiple linear regression is derived from given independent variable matrix with intercept X and dependent variable matrix Y, with m rows and n columns with n theta parameters? In Andrew Ng class, I am bit lost here on how this and non vectorized cost function are same? enter image description here



Solution 1:[1]

Ah! I think I got the answer. I forgot that what is happening is a square of a vector in the error part of the function. Hence it is transpose of vector.vector. Still not able to understand how X is defined with transposes of all independent variables in above definition, as I believe it is a matrix of dependent variables including intercept.

Solution 2:[2]

you got the error for each data point :( X*Theta - y ) when you transpose and do inner product. It is as same as squaring all the errors and taking a sum.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hari Prasad
Solution 2 doob