Context mixing is a type of data compression algorithm in which the next-symbol predictions of two or more statistical models are combined to yield a prediction that is often more accurate than any of the individual predictions. For example, one simple method (not necessarily the best) is to average the probabilities assigned by each model. The random forest is another method: it outputs the prediction that is the mode of the predictions output by individual models. Combining models is an active area of research in machine learning.
The PAQ series of data compression programs use context mixing to assign probabilities to individual bits of the input.
Suppose that we are given two conditional probabilities, P(X|A) and P(X|B), and we wish to estimate P(X|A,B), the probability of event X given both conditions A and B. There is insufficient information for probability theory to give a result. In fact, it is possible to construct scenarios in which the result could be anything at all. But intuitively, we would expect the result to be some kind of average of the two.
The problem is important for data compression. In this application, A and B are contexts, X is the event that the next bit or symbol of the data to be compressed has a particular value, and P(X|A) and P(X|B) are the probability estimates by two independent models. The compression ratio depends on how closely the estimated probability approaches the true but unknown probability of event X. It is often the case that contexts A and B have occurred often enough to accurately estimate P(X|A) and P(X|B) by counting occurrences of X in each context, but the two contexts either have not occurred together frequently, or there are insufficient computing resources (time and memory) to collect statistics for the combined case.
For example, suppose that we are compressing a text file. We wish to predict whether the next character will be a linefeed, given that the previous character was a period (context A) and that the last linefeed occurred 72 characters ago (context B). Suppose that a linefeed previously occurred after 1 of the last 5 periods (P(X|A) = 1/5 = 0.2) and in 5 out of the last 10 lines at column 72 (P(X|B) = 5/10 = 0.5). How should these predictions be combined?