**Introduction**

Mixture model is a weighted combinations of probability distributions. Mixture model is a powerful and well-understood tool for various problems in artificial intelligence, computer vision, and statistics. In this post, we will examine Gaussian mixture models, and algorithms to solve them.

Let’s first introduce Gaussian Mixture Model. Let be a collection of Gaussian distributions, with some associated weights . Let be set of observations that are generated by the above distributions.

**Figure 1**. Mixture of two Gaussian distributions, with , , .

We call this model **Mixture of Gaussians**. The parameter is called the **mixing portion of the Gaussians**.

By **solving** Gaussian Mixture Model, we are given a set of observed points and we want to **find the model parameters** ** that maximizes the posterior probability** .

**Figure 2.** Histogram of 10,000 points generated by the above Gaussian mixture model. We want to find the model parameters which maximizes the posterior probability of generating those points.

**K-means clustering**

K-means clustering solves a different problem, but K-means problem gives an insight over how we can solve the mixture of Gaussian problem. In K-means clustering, a set of observed points , a positive integer are given. We want to cluster the points into clusters so that it minimizes the within cluster sum of squares (WCSS).

is the mean of the cluster .

**Figure 3.** Example of a K-means clustering in 2 dimensions, K = 2. The observed points are clustered into the two clusters. The X mark denotes the centre of the cluster.

**Figure 4.** Another example of a K-means clustering in 2 dimensions, K=4.

**Expectation Maximization (EM)**

Expectation Maximization is an iterative algorithm for solving maximum likelihood problems. Given the set of observed data *X*, generated by the probability model with parameter 𝜃, we want to find the parameter 𝜃 that maximizes the posterior probability . In K-means clustering,

- – observed data
- – the clustering of the observed data points , and their associated centres .

EM Algorithm starts with an initial hypothesis for the parameter 𝜃 and iteratively calculate the posterior probability , and re-calculates the hypothesis 𝜃 each step. The details are going to be different between each EM algorithms, but the following are the approximate steps.

- Start with an initial hypothesis 𝜃.
**(Expectation step)**Calculate the posterior probability .**(Maximization step)**Categorize the observed data according to the probability, and update the hypothesis accordingly.- Repeat this process until the hypothesis converges.

**Algorithm – Hard K-means**

We assume that the , the likelihood of point belonging to the cluster centered at the point is 1 iff is the closest cluster.

During the **E-step**, the distances are calculated to determine . During the **M-step**, are determined by clustering each to the cluster closest to it. Finally, each are re-calculated by taking the mean of the points in .

**Figure 5**. Example of a K-means algorithm, for K=2. Initial cluster centres are randomly chosen from the observed points. Each iteration, the observed points are categorized to the nearest cluster centres, and the cluster centres are re-calculated. This process is repeated until the cluster centres converge.

**Algorithm – Soft K-means**

In Hard-K means. the observed points can only belong in a single cluster. However, it may be useful to consider the probability during the computation of . This is especially true for the points near a boundary between two clusters.

We want to calculate via the weighted average of with .

We assume that the likelihood has exponential distribution with the stiffness factor .

This way, is still monotonically decreasing with respect to the distance away from the centres, but the probability is panellized for the higher distance.

Similar to the Hard K-means algorithm, is obtained by normalizing this value.

**Algorithm – Gaussian K-means**

K-means algorithms are great, but the algorithm only reveals information about the cluster membership. However, we can modify the EM algorithm to calculate

We come back to the original assumption, that the likelihood follows a Gaussian distribution.

Where is the Gaussian probability density distribution. The actual probably is calculated as following.

We have to re-calculate three parameters, . Similar to the Soft K-mean algorithm, μ is the weighted averages of all . is the normalized ratio fo the sums . 𝜎 is the weighted standard deviation.

.

Where *I* is the dimensionality of *x*.

**Figure 6.** Points sampled from a mixture of two Gaussians. Top left plot is the data points generated by the model parameters , . The other plots show the results of Hard K-means, Soft K-means, and Gaussian K-means.

**Figure 7.** Another example of Gaussian K-means algorithm, with 4 clusters.

**References**

- http://en.wikipedia.org/wiki/K-means_clustering – K means clustering.
- http://www.inference.phy.cam.ac.uk/mackay/itila/ – Information Theory, Inference, and Learning Algorithm. Chapter 20, 22 has nice materials on K-mean clustering.