# 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$$

• @Tim: this doesn't really have anything to do with why we use squares for the standard deviation... – Stephan Kolassa Jul 17 '15 at 13:22
• @StephanKolassa right, I copy and pasted a link from a wrong window in browser... – Tim Jul 17 '15 at 13:25

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.