Overview

8 Mixture models: Modeling implicit group memberships

Mixture models are introduced as a way to handle data that appears to come from hidden subgroups, even when those groups are not directly observed. Instead of forcing one distribution to explain a multimodal dataset, the model assumes several component distributions are blended together, each representing a latent population. In the customer-spending example and the Old Faithful waiting-time data, this lets the model capture distinct patterns such as low, medium, and high spenders or short and long eruption waits that a single Gaussian would miss.

The chapter then shows how to build a Bayesian Gaussian mixture model by treating the mixture weights, means, and standard deviations as random variables. A Dirichlet prior is used for the weights because they must be nonnegative and sum to one, while normal and half-normal priors are used for component centers and spreads. Bayesian inference provides posterior distributions rather than just point estimates, which gives uncertainty over cluster locations, overlap regions, and membership probabilities for each datapoint. The chapter also highlights the label switching problem, where symmetric components can swap identities during sampling, and shows that ordering the component means is a practical fix that stabilizes inference without changing the model itself.

Finally, the chapter extends the idea to cases where the number of clusters is unknown by using the stick-breaking process, a Bayesian nonparametric approach inspired by Dirichlet processes. This procedure generates a potentially unbounded set of mixture weights from beta-distributed ratios, with a concentration parameter controlling whether the model prefers a few large groups or many small ones. In practice, the process is truncated to a manageable number of components, and the data determine which ones matter, as seen in the Old Faithful example where a larger model still identifies only two meaningful clusters. The chapter closes by pointing to real-world uses of mixture models in areas such as gene expression analysis, customer segmentation, and economics.

Example data showing multiple spending patterns that can’t be modeled using a single probability distribution.
A single Gaussian distribution cannot adequately model multiple modes within the data. The situation calls for a mixture model, where each component is responsible for capturing a mode.
Mixtures of varying numbers of Gaussians approximating a uniform distribution. As the number of components at our disposal increases, the quality of the approximation becomes higher.
The distribution of standardized waiting times between eruptions from the Old Faithful data.
Variables swap between two trends corresponding to the two clusters, illustrating the label switching problem.
Posterior predictive mean and samples of the mixture model against the observed data. The data lies in the middle of the posterior predictive range, showing that the posterior predictive distribution can model the data well.
Top: the observed data. Bottom: the probability that a given datapoint belongs to either cluster. The cluster membership probabilities reflect the trend in the observe data.
Demonstration of the stick-breaking process for a given list of ratios 𝛽. At each step, we break off the current stick based on the current ratio, and the remaining portion serves as the stick for the next iteration.
The effect of the concentration parameter 𝛼 of the beta distribution for the ratios 𝛽ᵢ on the stick-breaking weights 𝑤ᵢ
Trace plot from the 10-mixture model showing that the model detects 2 clusters from the data—the other clusters are deemed negligible.
The average weights of individual components in the mixture, averaged across posterior samples. Only the first 2 components have non-negligible weights.

Summary

  • Mixture models let us handle data that come from multiple hidden groups, without knowing the group of each observation.
  • Bayesian mixture models allow us to reason about our uncertainty in the cluster centers, widths, prevalences, and the membership of each datapoint.
  • Gaussian mixtures are especially popular: they can approximate any continuous distribution if we use enough components.
  • To avoid guessing the number of clusters, we can use the stick-breaking process, an iterative procedure to construct cluster weights. This process provides a prior that allows infinitely many clusters, but in practice only a few matter.
  • The concentration parameter 𝛼 of the stick-breaking process controls cluster richness: small 𝛼 favors fewer, larger clusters; large 𝛼 spreads weight across many small clusters.

FAQ

What is a mixture model?A mixture model is a probabilistic model that assumes each data point comes from one of several hidden groups or subpopulations, even though the group labels are not observed. The overall distribution is a weighted combination of the component distributions.
Why are mixture models useful for customer segmentation?They can uncover hidden customer types, such as bargain hunters, brand loyalists, high-spenders, or rare buyers, when no explicit labels exist. This helps model multimodal behavior that a single distribution cannot capture well.
Why can’t a single Gaussian model multimodal data well?A single Gaussian has only one peak, so it tends to either fit the largest mode and miss the others or spread too widely across all modes. As a result, it cannot represent multiple distinct clusters in the data.
How does a Gaussian mixture model represent multiple modes?It combines several Gaussian components, each with its own mean, standard deviation, and weight. The final density is the weighted sum of all component densities, letting the model capture multiple peaks in the data.
What do mixture weights mean in a Gaussian mixture?Mixture weights indicate how prevalent each hidden group is. They are non-negative and sum to 1, so they act like probabilities of selecting each component.
Why is Bayesian mixture modeling preferred over a non-Bayesian approach?A Bayesian mixture model gives full posterior distributions over parameters, not just point estimates. This lets us quantify uncertainty about cluster locations, sizes, overlap regions, and each datapoint’s group membership.
What is label switching in mixture models?Label switching happens because the mixture components are symmetric, so the sampler may swap component labels across draws. This can make trace plots look scrambled and cause convergence warnings.
How can label switching be reduced in practice?A common fix is to impose an ordering on the component means, such as always calling the smaller mean “Cluster 1” and the larger mean “Cluster 2.” This does not change the model, but it makes posterior samples easier to interpret.
What is the stick-breaking process?The stick-breaking process is a way to generate mixture weights without fixing the number of components beforehand. It starts with a unit-length stick and repeatedly breaks off portions; those pieces become the weights of the mixture components.
How does the Dirichlet process help model an unknown number of clusters?The Dirichlet process uses stick-breaking weights, often driven by Beta-distributed ratios, to allow a potentially unbounded number of components. In practice, only a few clusters get substantial weight, while the rest remain negligible.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes ebook for free