Growing the Context Tree (BIC / EBIC)
GrowthBook defines the leaves by greedily growing a binary decision tree over the context attributes, using an Extended Bayesian Information Criterion (EBIC) to decide when to stop splitting so the tree does not overfit the context.Model and notation
Within each leaf, a variation’s metric values are modeled as independent Gaussian draws around a leaf-and-variation-specific mean. Index the variations with sufficient data by . Let be variation ‘s total sample size across the tree and . For a given tree, let be variation ‘s residual sum of squares, pooled across all current leaves (each leaf’s residuals taken around that leaf’s sample mean for the arm). We leverage EBIC to minimize while controlling for the number of model parameters. Our approach does not require the raw data to be Gaussian, only the sample means, as we describe in Appendix: Deriving the Profile Log-Likelihood. The profiled Gaussian log-likelihood for arm (maximized over the variance) isA single split
Each binary split of a leaf gives every arm its own mean in each of the two children, adding parameters (one mean per arm). Let be the arm’s pooled SSE before the split and the pooled SSE afterward (the sum of the two children’s SSE). Because the per-arm sample sizes are unchanged by a split, the deviance (likelihood-ratio) improvement reduces to which equals twice the increase in the maximized log-likelihood.BIC stopping gate
BIC adds a complexity penalty for a model with parameters. A split adds parameters, so its BIC change is GrowthBook accepts a split only when it lowers BIC — that is, when , equivalently when the deviance improvement clears the penalty:EBIC multiplicity correction
At each growth step GrowthBook does not test a single pre-specified split. It searches every candidate split across all current leaves and their attributes and keeps the best one. Taking the arg-max over many candidates inflates the apparent improvement, so plain BIC under-penalizes. The Extended BIC (Chen & Chen, 2008) adds a term for the size of the searched model space. GrowthBook adds to the penalty: where- is the number of candidate binary partitions searched at that step, summed over all current leaves and their attributes, floored at . An attribute with distinct values in a leaf is split by enumerating every non-empty two-group partition, so it contributes candidates (for example, for a binary attribute and for values). Above a category cap the exact enumeration is replaced by an approximate local search, and the contribution is held at that cap’s value rather than growing exponentially.
- is the EBIC parameter. recovers plain BIC; is a Bonferroni-style correction across the candidates searched. GrowthBook currently fixes ; it is not configurable.
Growth algorithm
Starting from the root (a single leaf), at each step GrowthBook:- finds, for every current leaf, the candidate split that most reduces total SSE, then takes the global best across leaves;
- stops if no valid split remains or the best split does not strictly reduce SSE;
- computes for that split using the EBIC penalty above, stops if , and otherwise accepts the split and continues.
Thompson Sampling
Once the tree is built, GrowthBook sets the variation weights within each leaf by Thompson sampling, using the posteriors formed from that leaf’s data. Suppose we have variations, and we want to update the variation weights for a given context.For the -th variation, define its mean as , k = 1, …, K. Denote the probability that is larger than the other means as .
Under Thompson Sampling, is the variation weight for the -th variation. Define the posterior mean of as and its posterior variance as .
Define its posterior standard deviation as . Define the posterior distribution of as . This best-arm probability can be expressed as: We leverage the fact that the posterior distributions of the are normal and independent. The result above can be expressed as the expected value of the function below over the distribution of We use Gauss-Hermite quadrature to approximate the integral. Our integral is well suited for Gauss-Hermite quadrature, as the function inside the integral is smooth and light-tailed.
Let which implies that Define the standard normal distribution as . The integral can be represented as: Letting places the integral in the standard form for the Gauss-Hermite quadrature, which is
Prior Sample Size and Exploration
By default each arm’s posterior is formed from its own data under a diffuse conjugate prior, and the arms’ posteriors are independent — which is exactly what the best-arm probability above assumes. The optional prior sample size parameter (seen in the “Increase Bandit Exploration” setting) replaces that with a hierarchical model that partially pools the arms toward a shared mean, trading some exploitation for extra exploration. Within a leaf, let arm have sample size , sample mean , and distributional variance . The hierarchical model is where and are the diffuse hyperprior mean and variance. The middle line says the common-mean prior for each arm is worth pseudo-observations, which is the sense in which is a “prior sample size.” Writing the data precision as and the shrinkage factor as the shared mean has posterior and each arm’s posterior mean and variance (the and fed into the Thompson weights) are Larger increases , pulling every arm’s posterior mean toward the common mean and flattening the resulting weights, which increases exploration. Setting gives , so and the arms decouple, recovering the independent-arm setup above. Approximation when . The best-arm probability formula treats the posterior arm means as independent (it integrates a product of marginal normal CDFs). This is exact only when . When , every arm is shrunk toward the same estimated common mean , which makes the posterior arm means positively dependent through that shared term. GrowthBook still computes the weights by plugging the marginal posterior means and standard deviations into the independent-arm quadrature, so the Thompson probabilities are approximate — they do not account for the dependence among the means. Because the shared-mean uncertainty is common to all arms, ignoring it overstates the variance of the pairwise differences , which nudges the probabilities slightly toward uniform (a small additional amount of exploration beyond the shrinkage itself).Appendix: Deriving the Profile Log-Likelihood
The tree-growing criterion scores each arm with the profiled Gaussian log-likelihood Here is where that comes from. Fix an arm . Under the Gaussian model each observation () is drawn around the mean of whichever leaf it falls in, with a common within-arm variance , so that . The log-likelihood over the leaf means and the variance is Step 1 — profile out the means. Only the final term depends on the means, and it is minimized leaf-by-leaf by the within-leaf sample mean, . Substituting these, the residual sum of squares is Step 2 — profile out the variance. Differentiating the concentrated log-likelihood with respect to and setting it to zero, Step 3 — substitute back. The quadratic term collapses to a constant, , which yields the profiled form above. The split statistic follows immediately: comparing a tree to the same tree with one additional split, and the constants are identical before and after, soWhy only the means need to be normal
The derivation above assumes the individual observations are i.i.d. normal, which is what makes the exact MLE. But the procedure needs much less than that. The criterion only ever touches the data through group means and sums of squares, so maximizing is identical to minimizing — a least-squares (Gaussian quasi-likelihood) score that is sensible for any outcome with finite variance. What actually justifies the downstream inference — behaving like a likelihood ratio, and BIC’s penalty being the right scale — is the asymptotic normality of the estimated means, not of the raw outcomes. So the operative requirement is simply that the sample means are approximately Gaussian, which the Central Limit Theorem delivers whenever each leaf has enough units and the metric has finite variance. This is the same assumption the Thompson-sampling stage makes (normal posteriors on the ), so both stages rest on one consistent approximation. Consequently:- The raw data need not be Gaussian. Skewed, bounded, or binary metrics are fine as long as leaves are large enough for their means to be near-normal.
- This is why the per-leaf minimum-units requirement matters — it keeps each leaf mean in the regime where the normal approximation (and hence both the BIC score and the Thompson weights) is trustworthy.
- The pooled variance assumes homoscedasticity. Profiling to a single per arm treats the within-arm variance as roughly constant across leaves; if context-level variances differ substantially, plain SSE is a (usually mild) approximation of a variance-weighted criterion.

