Skip to content

Clustering, density estimation, and anomaly detection · Mixture and density models · UCL042 · Model

Dirichlet-process mixture model

Place a distribution over mixture complexity rather than fixing a finite number of occupied components in advance. It is useful for flexible density modeling when cluster count is uncertain.

Partly runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method covers part of this entry; some options or variants aren't built yet.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Partly runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through discover.gmm. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Place a distribution over mixture complexity rather than fixing a finite number of occupied components in advance. It is useful for flexible density modeling when cluster count is uncertain.

Question / hypotheses

Which probability model adequately explains the reference distribution and its latent heterogeneity? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.

Architecture / computational structure

A random discrete mixing measure, component likelihoods, and sampling or truncated variational inference.

Assumptions

Truncated variational implementations impose a computational cap; this cap must be checked. Occupied component count is not automatically a consistent estimate of a physical number of populations. Label switching and posterior uncertainty require careful summaries.

Formula / computational definition

G∼DP(α,G0)G\sim DP(\alpha,G_0), θi∼G\theta_i\sim G, and xi∼p(x∣θi)x_i\sim p(x\mid\theta_i). The concentration α\alpha controls prior partition behavior and G0G_0 supplies component-parameter priors. A Chinese-restaurant representation assigns an existing component probability proportional to its count and a new component probability proportional to α\alpha, before incorporating the data likelihood.

Parameters and notation

Learned or fitted quantities: Posterior component parameters, weights/partitions, and uncertainty summaries. User-set hyperparameters/design choices: Choose likelihood family, base distribution, concentration prior, and inference approximation. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.

Fitting, fine-tuning, and adaptation

Refit likelihood or posterior parameters on the new reference population; neural fine-tuning does not apply to this classical model. Warm starts can reduce computation but should be compared with fresh initialization. Recheck predictive fit and regularization after a domain shift.

How to use and calibrate

Assess predictive density, posterior co-clustering, concentration sensitivity, truncation saturation, and convergence of sampling or variational fitting.

Example application

Estimate a flexible density when occupied component count is uncertain. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.

Interpretation / pitfalls

Watch out

The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.

Python and R code examples

BayesianGaussianMixture with a Dirichlet-process weight prior supplies a truncated variational Gaussian implementation. R can bridge to it or implement a clearly specified sampler; finite-Dirichlet mixtures and DP mixtures should not be silently conflated.

Component: Dirichlet-process predictive partition prior. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Dirichlet-process predictive partition prior. · needs numpy

import numpy as np
counts=np.array([3.,2.,1.]); alpha=1.5
result=np.r_[counts,alpha]/(counts.sum()+alpha)
print(result)
R

Component demo, not a trained model — Dirichlet-process predictive partition prior.

counts=c(3,2,1); alpha=1.5; result=c(counts,alpha)/(sum(counts)+alpha)
print(result)

Sources

From the CodeSplash reference, entry UCL042.