# Why linear regression one variable uses squared cost function? [duplicate]

This is about linear regression course given by Andrew Ng on Coursea about machine learning. why cost function is $$\frac{1}{m} \sum _{i=1}^m \left(h_\theta(X^{(i)})-Y^{(i)}\right)^2$$

and not simply: $$\frac{1}{m} \sum _{i=1}^m \lvert h_\theta(X^{(i)})-Y^{(i)} \rvert$$

## marked as duplicate by Tim♦, S. Kolassa - Reinstate Monica, whuber♦Jul 17 '15 at 13:23

In the $Likelihood$ framework, the different cost functions arise when you take the Maximum Likelihood Estimate of your model parameters given different probabilistic assumptions that describe your situation.