Expectation Maximization
Coin Toss
Machine Learning
Statistical Methods
Probability

Expectation Maximization coin toss examples

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Expectation Maximization (EM) is a powerful statistical technique used for finding maximum likelihood estimates when dealing with incomplete data or when the model depends on latent variables. One of the most illustrative examples of applying the EM algorithm is solving the problem of estimating the bias of a coin when the outcome is partially hidden. The coin toss model provides an excellent introduction to understanding the nuances and applications of the EM algorithm.

Basics of Expectation Maximization

The EM algorithm consists of two main steps, which are iteratively applied:

  1. Expectation Step (E-Step): This step involves calculating the expected value of the latent variables, given the observed data and current estimate of the parameters.
  2. Maximization Step (M-Step): This step updates the parameter estimates by maximizing the expected log-likelihood found in the E-step.

EM iteratively applies these two steps to converge to a local maximum of the likelihood function.

Coin Toss Experiment

Setup

Consider an experiment with two coins, AA and BB, each with unknown biases θA\theta_A and θB\theta_B. We have a batch of experiments where:

• For each experiment, a coin is chosen at random with hidden probability. • The chosen coin is tossed a fixed number of times, say 10. • You observe only the total number of heads from the toss, but not the specific coin used.

The goal is to estimate θA\theta_A and θB\theta_B, the probability of heads for each coin, using the EM algorithm.

Technical Explanation

  1. Initialization: • Choose initial guesses for θA\theta_A and θB\theta_B, say θA(0)=0.6\theta_A^{(0)} = 0.6 and θB(0)=0.5\theta_B^{(0)} = 0.5.
  2. E-Step: • For each observation (number of heads), compute the probability that coin AA was used and the probability that coin BB was used, given the observed number of heads. • This involves using Bayes' theorem to update our knowledge about which coin might have been picked, incorporating the current estimates of the coin biases.
  3. M-Step: • With the probabilities from the E-step, update the estimates of θA\theta_A and θB\theta_B. For instance, if the probability that coin AA was used in an experiment is pAp_A, and the experiment resulted in hh heads out of 10 tosses, the updated formula for θA\theta_A might look like: θA(t+1)=pAh10pA\theta_A^{(t+1)} = \frac{\sum p_A \cdot h}{10 \sum p_A} • Similar update is conducted for θB\theta_B.
  4. Convergence: • Repeat the E-step and M-step until convergence, i.e., changes in θA\theta_A and θB\theta_B between iterations fall below a threshold.

Numerical Example

Consider data from 3 experiments with the following observed total heads:

ExperimentTotal HeadsCoin Used (Hidden)
18Unknown
27Unknown
39Unknown

Initialization:

θA(0)=0.6\theta_A^{(0)} = 0.6θB(0)=0.5\theta_B^{(0)} = 0.5

E-Step (iteration 1):

Calculate the probability that each experiment used coin AA based on initial guesses.

M-Step (iteration 1):

Calculate new estimates for θA\theta_A and θB\theta_B using probabilities from the E-step.

IterationθA\theta_AθB\theta_B
00.60.5
10.650.55
20.6750.585
.........

The above table illustrates the iterative update process where θA\theta_A and θB\theta_B converge to values that maximize the log-likelihood.

Applications and Importance

The coin toss example exemplifies the broader application of EM in various fields, such as:

Data Clustering: Discovering clusters in the data when the membership of data points is unknown. • Missing Data Problems: Estimating parameters where some data points are missing during a survey or experiment. • Gene Expression Analysis: Identifying gene patterns where the expression states are partially hidden or obscured.

The EM algorithm's ability to handle incomplete datasets makes it a crucial tool for statistical analysis, providing robust estimates in many practical situations.


Course illustration
Course illustration

All Rights Reserved.