Comparison of MLE and MAP Estimation using Sample Data
Experiment
Comparison of MLE and MAP Estimation using Sample Data
๐ฏ Aim
To estimate parameters using MLE and MAP and compare their behavior.
Objective
- Generate sample data
- Estimate mean using MLE
- Estimate mean using MAP (with prior)
- Compare results visually
๐ Theory
What are MLE and MAP?
๐น 1. Maximum Likelihood Estimation (MLE)
๐ Idea:
Find parameters that maximize the likelihood of observed data
๐ “Choose parameters that make the data most likely”
๐น 2. Maximum A Posteriori (MAP)
๐ Idea:
Includes prior knowledge about parameters
๐ “Choose parameters that fit data + prior belief”
๐ Key Difference
| Method | Uses Data | Uses Prior |
|---|---|---|
| MLE | ✅ | ❌ |
| MAP | ✅ | ✅ |
๐ง Intuition
- MLE → trusts only data
- MAP → balances data + prior belief
Assume:
- Data follows Normal Distribution
- Known variance
๐น MLE Estimate of Mean
MLE only uses the observed data.
Formula:
This is simply:
๐ sample mean
๐น MAP ( Maximum Aposteriori ) Estimate of Mean
๐ป Program
๐ Output
๐ Interpretation
๐น MLE
- Close to sample data
- Ignores prior
๐น MAP
- Pulled toward prior (5)
- Balances data + belief
Key Observation
| Scenario | Behavior |
|---|---|
| Large data | MLE ≈ MAP |
| Small data | MAP influenced by prior |
๐ Graph Explanation
- Histogram → data distribution
- Black line → true mean
- Blue line → MLE
- Red line → MAP
๐ MAP shifts toward prior
Result
MLE and MAP estimation were implemented and compared. MAP incorporates prior knowledge, whereas MLE relies solely on observed data.
- MLE is purely data-driven
- MAP incorporates prior belief
-
MAP is useful when:
- Data is limited
- Prior knowledge exists

Comments
Post a Comment