Log-likelihood
For positive independent-sample factors, log likelihood is the sum of their natural logarithms.
On this page 9 sections
01Understand the idea#
Multiplying many small likelihood factors can make a number too small for a computer to represent accurately. Taking logarithms turns the product into a sum. Because the logarithm increases with its input, maximizing a positive likelihood and maximizing its log give the same candidate.
For positive factors, has one factor and two factors. Its log is : every factor is retained.
Natural log turns an independent-sample product into a sum. Each factor must be positive for its log to be finite.
For likelihood factors , their product is . In base 2 the log-likelihood is , which is also . A negative log-likelihood changes the sign so that minimizing it corresponds to maximizing the original likelihood.
Positive factors . . Give .
Show answer and explanation
Log-term counts .
02For L=ab, use log L=log a+log b#
For , use . Multiplying the logs applies the wrong rule. If a factor appears three times, its log appears three times too.
Positive factors . . Reported . Repair.
Show answer and explanation
Log-term counts .
03An iid Bernoulli sample (1,0,1) has L(p)=p^2(1-p)#
An iid Bernoulli sample has . For , its log is . Natural log is increasing, so it preserves which positive likelihood is largest.
Ordered iid Bernoulli sample , , . Give .
Show answer and explanation
1 one, 3 zeros: use those log-term counts.
04Model training often adds a negative log-likelihood over examples#
Model training often adds a negative log-likelihood over examples. Keep the log base and sign clear when comparing reported losses. Logging a sum of probabilities is not a replacement for summing the logs of the independent likelihood factors.
Take one log term per positive factor. Keep multiplicities and every parameter-dependent term.
- Express an independent-sample likelihood as a sum of log terms.
Further questions
Does a log likelihood supply a prior over parameters?
Sources & further reading
- [1]Pishro-Nik, §8.2.3 Maximum Likelihood Estimation ↗Textbook · Book