skip to content

How do BIC and AIC choose the number of components for a Gaussian mixture?

level: seniorimportance: should knowfreq 44%

answer

  1. likelihood always improves with more components
  2. charge a price per free parameter
  3. two versus log of n
  4. lower score wins
  5. one is consistent, one predicts

basics

~10 s

Fit a mixture for each candidate component count and score it by a penalised log-likelihood: AIC charges 2 per free parameter, BIC charges log(n). Lower wins, so BIC selects fewer components than AIC.

solid answer

~50 s

Because a mixture is a likelihood model, you can score component counts directly rather than eyeballing a curve. Fit mixtures for `K = 1..10`, take each converged log-likelihood `L` and its free-parameter count `p`, then compute `AIC = -2L + 2p` and `BIC = -2L + p*log(n)`. Lower is better for both. `p` counts everything: `K-1` free weights, `K*d` mean entries, plus the covariance parameters, which is where the covariance form dominates the count. On an ad-auction bid-price distribution swept over 1 to 10 components, BIC typically bottoms out earlier than AIC, because for any `n > 8` the factor `log(n)` exceeds 2 and BIC punishes complexity harder. The two answer different questions: BIC is consistent for recovering a true component count when the model family is correct, AIC targets predictive accuracy and tends to over-select. Always run several initialisations per `K` and score the best converged fit, or you are comparing initialisation luck rather than models.

go deeper

for a junior

Remember the shape of the method: fit several component counts, score each with a number that rewards fit and charges for complexity, and pick the lowest score rather than the best raw likelihood.

for a middle

Write both formulas, state that lower wins, and count the free parameters correctly including K minus 1 weights and the covariance entries implied by the covariance form.

for a senior

Show operational care: restarts per K, discarding collapsed fits, reading a monotonically falling curve as a wrong-family signal, and cross-checking with held-out log-likelihood before committing.

for a principal

Own the decision the criterion cannot make. Say whether the component count is a deliverable or a smoothing knob, cap it by what the organisation can act on, and set the house convention for which criterion is quoted and how ties are broken.

## Why a mixture lets you do this at all A Gaussian mixture is a probabilistic model of the data, so a fit comes with a number that a purely geometric partition does not have: the **log-likelihood** of the observed data under the fitted model. That opens the door to standard model-selection machinery. You cannot simply pick the `K` with the highest log-likelihood — adding components can only ever fit better, so the likelihood rises monotonically with `K` and the maximum is always at the largest `K` you tried. Information criteria fix that by charging for parameters. ## The two criteria For a fitted model with maximised log-likelihood `L`, `p` free parameters and `n` observations: ``` AIC = -2 * L + 2 * p BIC = -2 * L + p * log(n) ``` Both are on a "lower is better" scale, because the `-2L` term turns a higher likelihood into a lower score. The **only structural difference** is the price per parameter: a flat 2 for AIC, `log(n)` for BIC. Since `log(n) > 2` whenever `n > e^2`, roughly 8, BIC charges more than AIC on any real dataset, and the gap widens with sample size — at `n = 10,000`, BIC pays about 9.2 per parameter against AIC's 2. **BIC therefore selects the same or fewer components than AIC**, essentially always. ## Counting the parameters correctly Getting `p` right matters, because the penalty is built entirely from it. For `K` components in `d` dimensions: - Mixing weights: `K - 1` free, not `K`, since they must sum to 1. - Means: `K * d`. - Covariances: `K * d(d+1)/2` for full covariance, `K * d` for diagonal, `K` for spherical. So for `K = 3`, `d = 2`, full covariance: `2 + 6 + 9 = 17`. Note that the covariance form changes `p` dramatically, which means the criteria let you compare covariance forms and component counts **in the same sweep** — a diagonal mixture with 5 components and a full-covariance mixture with 3 are directly comparable if you count parameters honestly for each. ## How the sweep is actually run Take a bid-price distribution from an ad auction and fit `K = 1` through `K = 10`. For each `K`: 1. Run EM from several different initialisations, because EM converges only to a local optimum. Keep the run with the highest converged log-likelihood. 2. Record that log-likelihood, the parameter count and the criterion values. 3. Discard any run with a collapsed component — a degenerate fit has an inflated log-likelihood and will win the sweep for the wrong reason. Then plot both curves against `K`. You are looking for a minimum. Typical outcome: BIC bottoms at, say, 3 and rises after; AIC bottoms at 5 or 6 and stays flatter. That divergence is expected and is not a sign that one of them is broken. ## Reading the curves honestly **A clear minimum.** Take it, then sanity-check the fitted components against the domain. Also look at the *shape*: if `K = 3` and `K = 4` are within a couple of BIC points of each other, the data is not distinguishing them and you should choose on interpretability or downstream cost, not on the second decimal place. **A curve that keeps falling to the edge of the sweep.** This is the common real-world result and it usually means the true density is not a small number of Gaussians. The mixture is using components as basis functions to approximate a skewed or heavy-tailed shape, and each extra bump genuinely improves the fit. Two responses: transform the feature so it is closer to Gaussian (a log transform on prices often collapses ten components into two), or accept that you are density-estimating rather than segmenting, in which case the component count is a smoothing knob and not a count of populations. **A noisy curve with several local dips.** Almost always an initialisation problem. Increase the number of restarts per `K` and re-run before interpreting anything. ## Which one to prefer They optimise different targets, and the honest answer names both: - **BIC** is derived as an approximation to the model evidence and is *consistent*: if the data really were generated by a finite Gaussian mixture, BIC selects the true component count with probability approaching 1 as `n` grows. Choose BIC when the component count is the deliverable — when someone will act on "there are three segments". - **AIC** approximates expected out-of-sample predictive loss. It is not consistent and tends to over-select, but the extra components often help if you only care about how well the model predicts. Choose AIC when the mixture is a density estimator feeding something downstream. - **Held-out log-likelihood** is the third option and often the most convincing: split the data, fit on one part, evaluate the log-likelihood of the other. It makes no asymptotic assumptions and it is the argument stakeholders find easiest to accept. ## Caveats worth voicing Both criteria rest on regularity conditions that mixture models technically violate — component labels are exchangeable and the parameter space has boundaries where a component vanishes — so treat them as well-tested heuristics rather than theorems in this setting. Both assume the same `n` and the same data across every fit, so you cannot compare a criterion computed on one feature set against one computed on another. And neither knows anything about your business: a component count that is statistically justified and operationally unusable is a bad answer. The criterion narrows the field; a domain constraint on how many segments the organisation can actually act on closes it.

  • Which selects more components, AIC or BIC, and why?
    AIC. The criteria differ only in the price per parameter: AIC charges 2, BIC charges log(n). Once n exceeds about 8, log(n) is larger, and at n = 10,000 it is roughly 9.2. BIC therefore penalises each extra component's parameters far more heavily and bottoms out at a smaller K. AIC targets predictive loss and tolerates the extra flexibility.
  • Your BIC curve falls all the way to K = 10 with no minimum — what now?
    Read it as evidence that the data is not a handful of Gaussians. The mixture is approximating a skewed or heavy-tailed density with extra bumps, and each one genuinely raises the likelihood. Try a transform that makes the feature closer to Gaussian, extend the sweep to see whether a minimum exists further out, and decide whether you are segmenting — in which case the count matters — or density-estimating, in which case it is just a smoothing knob.
  • Can you compare a full-covariance mixture and a diagonal one with the same criterion?
    Yes, provided you count parameters correctly for each — d(d+1)/2 per component for full, d for diagonal — and both are fitted to the same n rows and the same features. The criterion then trades the full model's better fit against its much larger penalty, and a diagonal model with more components frequently wins in higher dimensions.
  • Why must you run several initialisations before scoring each K?
    Because EM converges to a local optimum, so a single run's log-likelihood reflects initialisation luck as much as the value of K. If K = 4 happened to get a good start and K = 5 a poor one, the criterion compares starts rather than models and the curve becomes noisy with spurious dips. Take the best converged run per K, and discard any run with a collapsed component.

saying these in an interview costs you the question

  • Picks the component count with the highest log-likelihood outright
  • Says higher AIC or BIC is better
  • Thinks BIC selects more components than AIC
  • Counts K free mixing weights instead of K minus 1
  • Scores a single EM run per K without restarts
  • Ignores that the covariance form changes the parameter count

context