TOC
What is maximum likelihood estimate (MLE)?When is it used ?The basic intuition behind using maximum likelihood to fit a logistic regression model:What is its function name ?Why MLE?Q1. Why MLE ?Q2. Why is log better?How do we do this process mathematically? Both sources tell us to to set derivative to zero : Example 1 : Finding the mean given variance (Fleshman)Example 2 : 55 heads out of 100 flips, find the MLE for the probability p of heads on a single toss. (MIT)Step 1 : understand the annotations.Step 2 : After knowing the definition, compute the which is a notation for the MLE.Example 3 : 9 heads out of 13 flips, find the MLE for the probability p of heads on a single toss. (didl)Step 1 : understand the annotations and scenarioAssumption ScenarioStep 2 : Step 2 : Compute the ^ which is a notation for the MLE.So the answer is 9/13, which makes sense.Example : ETC3250 BrendiMathShorten the log likelihood (ETC3250)Reference :
TOC by what why how
What is maximum likelihood estimate (MLE)?
From (MIT) :
- There are many methods for estimating unknown parameters from data, one of which is MLE.
- It answer :
For which parameter value does the observed data have the biggest probability?
- a point estimate because it gives a single value for the unknown parameter
When is it used ?
- The concept that when working with a probabilistic model with unknown parameters, the parameters which make the data have the highest probability are the most likely ones. (didl)
The basic intuition behind using maximum likelihood to fit a logistic regression model:
- We try to find and such that plugging these estimates into the model for .(statl)
What is its function name ?
- It is called : maximum likelihood estimator (ETC2420 Lecture week 4)
Why MLE?
Q1. Why MLE ?
- Simple to compute. (MIT)
- Intuitively appealing —
- we try to find the value of the parameter that would have most likely produced the data we in fact observed. (Libretexts)
- find the maximum of that function, i.e. the parameters which are most likely to have produced the observed data. (Fleshman)
- Better than least squares method (non-linear) ∵ it has better statistical properties. (statl)
- Least squares approach is in fact a special case of maximum likelihood. (statl)
Q2. Why is log better?
- It is often easier to work with the log likelihood. (MIT)
- Problem : (Fleshman)
- Taking the product of small numbers creates smaller numbers, which computers can struggle to represent with finite precision.
- Solution : (Fleshman)
- To alleviate these numerical issues (and for other conveniences mentioned later), we often work with the log of the likelihood function, aptly named the log-likelihood.
- Why does taking the log help? Details are explained.
How do we do this process mathematically?
Both sources tell us to to set derivative to zero :
- We could find the MLE by finding the values of θ where the derivative is zero, and finding the one that gives the highest probability. (didl)
- If you’re familiar with calculus, you’ll know that you can find the maximum of a function by taking its derivative and setting it equal to 0. The derivative of a function represents the rate of change of the original function. (Fleshman)
There are 3 examples, 2 of which are about flipping the coins. The same intuition and logic but from different sources ( Example 2, 3). Another one is about finding the mean given variance (Example 1).
Example 1 : Finding the mean given variance (Fleshman)
Imagine we have some data generated from a Gaussian distribution with a variance of 4, but we don’t know the mean.
I like to think of MLE as taking the Gaussian, sliding it over all possible means, and choosing the mean which causes the model to fit the data best.
![we see the maximum of the log-likelihood occur at a mean of 2. In fact, that is the true mean of the distribution which created the histogram!](https://www.notion.so/image/https%3A%2F%2Fmiro.medium.com%2Fmax%2F900%2F1*jxZFpWtCbD4jHPV0DdDuMA.gif?table=block&id=21ec2771-648f-4173-9f71-aa7e74879144&cache=v2)
If you look at the log-likelihood curve above, we see that
- initially it’s changing in the positive direction (moving up). It reaches a peak,
- and then it starts changing in a negative direction (moving down).
The key is that at the peak, the rate of change is 0.
So if we know the functional form of the derivative, we can set it equal to 0 and solve for the best parameters.
Example 2 : 55 heads out of 100 flips, find the MLE for the probability p of heads on a single toss. (MIT)
A coin is flipped 100 times. Given that there were 55 heads, find the maximum likelihood estimate for the probability p of heads on a single toss.
Definition of what we are finding:
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fb71669b2-5793-4e6c-9ea2-15693cb1de55%2FUntitled.png%3Ftable%3Dblock%26id%3Ded2f7693-fd97-4a65-9457-485119d3f146%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3Dq0cbDeZpK1ktQYrWyPOorYqqOR3hLBvgkrsIEjcg5_c?table=block&id=ed2f7693-fd97-4a65-9457-485119d3f146&cache=v2)
Step 1 : understand the annotations.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F54b3517c-e4b3-43fd-a4c4-3cfe5b035489%2FUntitled.png%3Ftable%3Dblock%26id%3D4287af9b-7bfa-4268-9e9e-8252ef669074%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3D0LgT-DCI0IDPbCNvhOWxcnzF1f4ToZa2d-_P167ZqmI?table=block&id=4287af9b-7bfa-4268-9e9e-8252ef669074&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fc7f13789-5d99-4fcd-8933-8b6f5797e741%2FUntitled.png%3Ftable%3Dblock%26id%3D47bf7458-aea3-4578-bc10-a28e3c3eae3a%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DUcROx29dVBXJ36xK5JiQJFhV688XFaADGI-xRNU7USc?table=block&id=47bf7458-aea3-4578-bc10-a28e3c3eae3a&cache=v2)
Step 2 : After knowing the definition, compute the which is a notation for the MLE.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F766685a5-e55d-4366-9cb3-e11ad20a229c%2FUntitled.png%3Ftable%3Dblock%26id%3D878fb04b-6e90-4a66-80b4-912b34e2457f%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3Dp8hb4Qi13uKLbxhQwO_7BIaFS9BSxCgoyR18-WllHg8?table=block&id=878fb04b-6e90-4a66-80b4-912b34e2457f&cache=v2)
![2.1. Using Calculus to solve the left part.](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F1cf2d432-1a64-4fb6-b664-9fc8c6e82738%2FUntitled.png%3Ftable%3Dblock%26id%3Db5433076-7298-416e-92a3-3e3b5bf705af%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DKCAj6MHX5J7NQLJlbJ9PhrhVQSqTrs7leVv7tl1lBeo?table=block&id=b5433076-7298-416e-92a3-3e3b5bf705af&cache=v2)
2.2. at the end :
![RMB : We could find the MLE by finding the values of θ where the derivative is zero, and finding the one that gives the highest probability.](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fbeeb56d9-a26e-406b-ae90-148e2410b412%2FUntitled.png%3Ftable%3Dblock%26id%3D5527b96a-8c0a-41b8-8de4-3b3c32e329ab%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DFIZbukUM_Lab_75sbMS8MOs4ZU1mPOYbVpAiPpnYkNQ?table=block&id=5527b96a-8c0a-41b8-8de4-3b3c32e329ab&cache=v2)
Example 3 : 9 heads out of 13 flips, find the MLE for the probability p of heads on a single toss. (didl)
Question in laymen sense :
I flipped 13 coins, and 9 came up heads, what is our best guess for the probability that
the coin comes us heads?
Step 1 : understand the annotations and scenario
Assumption
- Suppose that we have a single parameter θ representing the probability that a coin flip is heads. Then the probability of getting a tails is 1−θ.
- If our observed data X is a sequence with heads and tails, we can use the fact that independent probabilities multiply to see that
Scenario
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F1f3c465f-32ce-4472-afee-92bbdba353e7%2FUntitled.png%3Ftable%3Dblock%26id%3D14e07702-b1b6-48e0-8e87-496e2cc259a7%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DNrmWoZ0PMRJm4l_Uqy9OanTtyjnXv_e30FkhEx-e6mc?table=block&id=14e07702-b1b6-48e0-8e87-496e2cc259a7&cache=v2)
Step 2 : Step 2 : Compute the ^ which is a notation for the MLE.
RMB : We could find the MLE by finding the values of θ where the derivative is zero, and finding the one that gives the highest probability.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fb1752e79-91d4-4791-b81f-4346de6ee032%2FUntitled.png%3Ftable%3Dblock%26id%3Db5658e3d-50b7-4a46-9808-8f8b70f2afea%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DgEk8BVXFn6qhmdpC9PCnJeDtffxk_W3lwJJunmSqEe0?table=block&id=b5658e3d-50b7-4a46-9808-8f8b70f2afea&cache=v2)
![Type : x^9 (1-x)^4 in here](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F8ab91416-7889-4dd8-89ae-e0161179831e%2FUntitled.png%3Ftable%3Dblock%26id%3Df5afa04e-7a5d-4b73-b492-b0bf24f7e707%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DtY4CYxJ5cnxddUhmTc8SHhyrhd6jNJxPZCF7RaV2yT8?table=block&id=f5afa04e-7a5d-4b73-b492-b0bf24f7e707&cache=v2)
So the answer is 9/13, which makes sense.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fcb921269-22c0-49b2-9f06-e8e290b9156e%2FUntitled.png%3Ftable%3Dblock%26id%3Dcf275a09-4e8d-4821-a33f-ff4466a5f416%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DyeSpz__1QoOEXCKrGA7490dvhI6y33vxB0GQw-bvtLM?table=block&id=cf275a09-4e8d-4821-a33f-ff4466a5f416&cache=v2)
![This has its maximum value somewhere near our expected 9/13 ≈ 0.7](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fc1f19ffb-acd2-49ef-b9c3-a40845b64a3a%2FUntitled.png%3Ftable%3Dblock%26id%3Da5513348-b94a-485b-b343-d0852c4fe20d%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3D9msPZcpbqULfZMpTvODe7idDnYdT3gLE_1x9gauiwM0?table=block&id=a5513348-b94a-485b-b343-d0852c4fe20d&cache=v2)
Code can be found in book.
Example : ETC3250 Brendi
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fcd04d99a-679a-410e-8879-3712c7467ae9%2FUntitled.png%3Ftable%3Dblock%26id%3D06751cb0-4bb5-4179-b659-086fd8b58718%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3Dga9DSZ_9eHyc6WhrzD10Jn2wHiXIjaysCTPV6nunaUk?table=block&id=06751cb0-4bb5-4179-b659-086fd8b58718&cache=v2)
Math
The concept and mathematical representation in general can be found here. (Fleshman)
Shorten the log likelihood (ETC3250)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F574fbd70-4d19-4061-bca6-7a9c78675e42%2FUntitled.png%3Ftable%3Dblock%26id%3Da9297333-5482-40e4-ae95-bd63757483b5%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DYUtoeo7TKW0T9tXQGZfMhz9h5SQYlm-ZR7yZPuDjkOg?table=block&id=a9297333-5482-40e4-ae95-bd63757483b5&cache=v2)
Reference :
(Here)
- didl : Zhang, A. (2021). Dive into Deep Learning. (Here)
- statl : James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An Introduction to Statistical Learning: with Applications in R (Springer Texts in Statistics) (2nd ed. 2021 ed.). Springer. (Here)
- MIT : MLE Intro. Jeremy Orloff and Jonathan Bloom (Here)
- Libretexts. (2020, August 10). 7.3: Maximum Likelihood. Statistics LibreTexts. https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/07%3A_Point_Estimation/7.03%3A_Maximum_Likelihood
- Fleshman, W. (2019, March 9). Fundamentals of Machine Learning (Part 2) - Towards Data Science. Medium. https://towardsdatascience.com/maximum-likelihood-estimation-984af2dcfcac