Log-likelihood (source code)

= Log-likelihood
{title2=$\ell(\theta;x)=\log L(\theta;x)$}

= Log-likelihood function
{synonym}

The <log-likelihood> is the <natural logarithm> of the <likelihood function>:
$$
\ell(\theta;x)=\log L(\theta;x).
$$
For positive finite <likelihood>, the <natural logarithm> is a <strictly increasing function>, so the maximizing parameter values are unchanged. Set $\ell=-\infty$ where $L=0$; the same ordering then includes zero-likelihood boundaries whenever a positive finite maximum exists. For <independent and identically distributed random variables>, a product becomes a sum,
$$
L(\theta;x)=\prod_{i=1}^n f_\theta(x_i),\qquad \ell(\theta;x)=\sum_{i=1}^n\log f_\theta(x_i).
$$
This makes <derivatives> simpler and avoids forming products of tiny numbers in <floating-point arithmetic>. These equal-maximizer and additive formulas underlie the worked calculations in https://ocw.mit.edu/courses/18-05-introduction-to-probability-and-statistics-spring-2022/mit18_05_s22_class10-prep-b.pdf[MIT 18.05, Reading 10b, section 3.1].

For the ordered sample of eight successes and two failures in <likelihood function>, on $0<p<1$,
$$
\ell(p)=8\log p+2\log(1-p),\qquad \ell'(p)=\frac8p-\frac2{1-p},\qquad \ell''(p)=-\frac8{p^2}-\frac2{(1-p)^2}<0.
$$
The <score equation> $\ell'(p)=0$ gives $8(1-p)=2p$, hence $\widehat p=8/10=0.8$. The negative <second derivative> proves <strict concavity>, so this is the unique interior maximum. Both counts are positive, so $L(0)=L(1)=0$, while $L(p)>0$ inside: the same point is the unique global <maximum> on $[0,1]$. Counting only successes adds $\log45$ to the <log-likelihood>, leaving both <derivatives> and the <MLE> unchanged. For all-success or all-failure samples, the boundary analysis in <maximum-likelihood estimator> applies instead of an interior <score equation>.

The two panels below compare $k=2,5,8$ successes out of ten <Bernoulli trials>. Their peaks are at $\widehat p=k/10$. The left panel uses relative height; the right panel uses the <log-likelihood> difference from each peak. These are the same comparison on two scales:
$$
\ell(p)-\ell(\widehat p)=\log\frac{L(p)}{L(\widehat p)},\qquad \frac{L(p)}{L(\widehat p)}=\exp\bigl(\ell(p)-\ell(\widehat p)\bigr).
$$
A difference of $-2$ means relative height $e^{-2}$, and a difference of $-10$ means $e^{-10}$; the <log-likelihood> scale makes small relative heights easier to see. Neither vertical axis is a parameter <probability density function>. The zero <likelihood> endpoints have <log-likelihood> $-\infty$ and are outside the finite vertical range in the right panel.

\Image[/bernoulli-likelihood-and-log.png]
{title=Ten Bernoulli trials: relative likelihood heights and log-likelihood differences share the same peaks}

Multiplying a <likelihood function> by a positive parameter-independent constant adds a constant to its <log-likelihood>. Subtracting its peak removes that constant. This is why the ordered-data and count-data curves coincide in this figure after rescaling. When differentiable, the <gradient> of the <log-likelihood> is the <score function>; the negative <Hessian matrix> is the <observed information>. A solution of a <score equation> still needs checking against other stationary points and boundaries: maximizing the <log-likelihood> does not automatically make it <concave>.