4
$\begingroup$

A cost function used in machine is often the following

$$C = \frac{1}{2} \| y - \hat{y} \| ^2$$

Why is there $\frac{1}{2}$ in front of the squared distance?

$\endgroup$
1

1 Answer 1

4
$\begingroup$

To simplify the derivative, probably. Otherwise there will be constant 2 in it.

$\endgroup$
3
  • 2
    $\begingroup$ This is the correct answer. The constant factor does not affect the optimizer of the loss, so the only reason is convenience. $\endgroup$
    – Harsh
    Feb 23, 2017 at 21:16
  • $\begingroup$ I think it would also useful if you explain in which way it exactly simplifies the derivative (i.e. show a step by step example). $\endgroup$
    – nbro
    Apr 1, 2019 at 13:56
  • $\begingroup$ @Harsh Yes, but I think these details should be elaborated a little more (i.e. explained more in detail), given that they might not obvious to everyone, so this question needs to be improved, IMHO. $\endgroup$
    – nbro
    Apr 1, 2019 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .