On the Complexity of A/B Testing
Emilie Kaufmann, Olivier Cappé, Aurélien Garivier
Introduction
A/B Testing is a popular procedure used, for instance, for website optimization: two versions of a webpage, say A and B, are empirically compared by being presented to users. Each user only sees one of the two versions, and the goal is to determine which version is preferable. We assume that the users provide a real-valued index of the quality of the pages, which is modeled by probability distributions and , with respective means and . For example, a standard objective is to determine which webpage has the highest conversion rate (probability that a user actually becomes a customer) by receiving binary feedback from the users.
Methods for A/B Testing are often viewed as statistical tests of the hypothesis against . One may consider either classical tests, based on a number of samples and from each distribution fixed before the experiment, or sequential tests, based on paired samples () of and in which a randomized stopping rule determines when the experiment is to be terminated. In both of these test settings, the sampling schedule is determined in advance, which is a possible source of sub-optimality as A/B Testing algorithms could take advantage of past observations to provide a smarter choice of the page to be displayed to the next user. In the sequel, we investigate whether A/B Testing could benefit from an adaptive sampling schedule. Ignoring the possible long-term effects on users of presenting one or the other option, we consider it as a particular instance of best arm identification in a two-armed bandit model.
In order to unify and compare these approaches, we define the complexity (resp. ) of best arm identification in the fixed-confidence (resp. fixed-budget) setting, as follows:
Heuristically, for a given bandit model and a given , a fixed-confidence optimal strategy uses an average number of samples of order , whereas a fixed-budget optimal strategy uses approximately draws in order to ensure a probability of error at most equal to . Most of the existing performance bounds for the fixed confidence and fixed budget settings can be expressed using these complexity measures.
where denotes the Kullback-Leibler divergence between distributions and . Since then, non-asymptotic analyses of efficient algorithms matching this bound have been proposed. Optimal algorithms include the KL-UCB algorithm of [Cappé et al. (2013)]—a variant of UCB1 ([Auer et al. (2002)]) using informational upper bounds, Thompson Sampling ([Kaufmann et al. (2012b), Agrawal and Goyal (2013)]), the DMED algorithm (Honda and Takemura, 2011) and Bayes-UCB Kaufmann et al. (2012a). This paper is a first step in the attempt to similarly characterize the complexity of pure exploration, where the goal is to determine the best arms without trying to maximize the cumulated observations.
The fixed-budget setting has been studied recently by Audibert et al. (2010); Bubeck et al. (2013). In two-armed bandit problems, the algorithms introduced in these papers boil down to sampling each arm times— denoting the total budget—and recommending the empirical best arm. A simple upper bound on the probability of error of this strategy can be derived, and this result paired with the lower bound of Audibert et al. (2010) yields, for bounded bandit models such that for :
Bubeck et al. (2011) show that in the fixed-budget setting any sampling strategy designed to minimize regret performs poorly with respect to the simple regret , a quantity closely related to the probability of recommending the wrong arm. Therefore, good strategies for best arm identification have to be quite different from UCB-like strategies. We will show below that the complexities and of pure-exploration involve information terms that are different from the Kullback-Leibler divergence featured in Lai and Robbins’ lower bound on regret.
Contents of the paper. Compared to existing results, we provide general lower bounds on and that: (i) are tighter, leading in specific parametric cases to a precise evaluation of these complexities; (ii) do not require unnecessary support assumptions; and (iii) are stated in terms of information divergences between the distributions and rather than in terms of the gap . As can be expected, we will indeed confirm that the inverse of the squared gap is the relevant measure of complexity only in the Gaussian case, and an approximation (in the spirit of Pinsker’s inequality) for sub-Gaussian distributions.
Lower bounds on the sample complexity (resp. probability of error) of algorithms using the uniform sampling strategy in the fixed-confidence (resp. fixed-budget) setting are also derived and we show that for Gaussian bandit models with different variances, there is a significant gain in using a non-uniform sampling strategy. For Bernoulli bandits however, we show that little can be gained by departing from uniform sampling, and we therefore propose close-to-optimal tests both for the batch and sequential settings. For Gaussian bandits with a known common variance the optimal algorithm uses uniform sampling. In this specific case, we propose an improved -PAC stopping rule, illustrating its performance through numerical experiments.
Our contributions follow from two main mathematical results: Lemma 6.1 provides a general relation between the expected number of draws and Kullback-Leibler divergences of the arms’ distributions, which is the key element to derive the lower bounds. Lemma 6.2 is a tight deviation inequality for martingales with sub-Gaussian increments, in the spirit of the Law of Iterated Logarithm.
The paper is structured as follows. Section 2 presents a distribution-dependent lower bound on both and under the some identifiability assumption, as well as lower bounds for algorithms using uniform sampling. Gaussian bandit models are then studied in details in Section 3, and Bernoulli bandit models in Section 4. Section 5 includes a practical illustration of the performance of matching algorithms for Gaussian bandits, as well as a practical comparison of the fixed-confidence and fixed-budget settings. The most important elements of proof are gathered in Section 6, with the rest of the proofs in the Appendix.
Lower Bounding the Complexity
Introducing the Kullback-Leibler divergence of any two probability distributions and :
we make the assumption that there exists a set such that for all , for and that satisfies
A class of bandit models satisfying this property is called identifiable. For an identifiable class of bandit models, Theorem 2.1 provides lower bounds on and for every . The proof of this theorem is based on changes of distribution and detailed in Section 6.
Let be a two-armed bandit model such that . In the fixed-budget setting, any consistent algorithm satisfies
In the fixed-confidence setting any algorithm that is -PAC on satisfies, when ,
In particular, Theorem 2.1 implies that and . Proceeding similarly, one can obtain lower bounds for the algorithms that use uniform sampling of both arms. The proof of the following result is easily adapted from that of Theorem 2.1 (cf. Section 6), using that each arm is drawn times.
Let be a two-armed bandit model such that . In the fixed-budget setting, any consistent algorithm using a uniform sampling strategy satisfies
In the fixed-confidence setting, any algorithm that is -PAC on and uses a uniform sampling strategy satisfies, for ,
Obviously, one always has and suggesting that uniform sampling can be sub-optimal. It is possible to give explicit expressions for the quantities and for specific classes of parametric bandit models that will be considered in the rest of the paper. In the case of Gaussian bandits with known variance (see Section 3):
Hence, the lower bounds of Theorem 2.1 are equal in this case, and we provide in Section 3 matching upper bounds confirming that indeed . In addition, the observation that implies that, except when , strategies based on uniform sampling are sub-optimal.
The values of and can also be computed for canonical one-parameter exponential families with density with respect to some reference measure given by
For exponential family bandits the quantities and are not equal in general, although it can be shown that it is the case when the log-partition function is (Fenchel) self-conjugate (e.g., for Gaussian and exponential variables). In Section 4, we will focus on the case of Bernoulli models for which . By exhibiting a matching strategy in the fixed-budget case, we will show that this implies that in this case.
The Gaussian Case
We study in this Section the class of two-armed Gaussian bandit models with known variances defined by (1), where and are fixed. In this case, we observed above that the lower bounds of Theorem 2.1 are similar, because . We prove in this section that indeed
by exhibiting strategies that reach these performance bounds. These strategies are based on the simple recommendation of the empirical best arm but use non-uniform sampling in cases where and differ. When we provide in Theorem 3.1 an improved stopping rule that is -PAC but results in a significant reduction of the running time of fixed-confidence tests.
We consider the simple family of static strategies that draw samples from arm 1 followed by samples of arm 2, and then choose arm 1 if , where denotes the empirical mean of the samples from arm . Assume for instance that . Since , the probability of error of such a strategy is easily upper bounded as:
The right hand side is minimized when , and the static strategy drawing times arm 1 is such that
which matches the bound of Theorem 2.1 for Gaussian bandit models.
2 Fixed-Confidence Setting
We start with the simpler case , where the quantity introduced in Theorem 2.2 coincides with , which suggests that uniform sampling could be optimal. A uniform sampling strategy is equivalent to collecting paired samples from both arms. The difference is Gaussian with mean and a -PAC algorithm is equivalent to a sequential test of versus such that the probability of error is uniformly bounded by . Robbins (1970) proposes such a test that stops after a number of samples
Note that any elimination strategy that is -PAC and uses a threshold function smaller than Robbins’ also matches our asymptotic lower bound, while being strictly more efficient than Robbins’ rule. For practical purpose, it is therefore interesting to exhibit smaller exploration rates leading to a -PAC algorithm. The probability of error of such an algorithm is upper bounded, for example for by
where is a sum of i.i.d. variables of distribution . Robbins (1970) obtains a non-explicit confidence region of risk at most by choosing . The dependency in is in some sense optimal, because the Law of Iterated Logarithm (LIL) states that almost surely. Recently, Jamieson et al. (2013) proposed an explicit confidence region inspired by the LIL. However, Lemma 1 of (Jamieson et al., 2013) cannot be used to upper bound (4) by and we provide in Section 6 a result derived independently (Lemma 6.2) that achieves this goal and yields the following result.
For small enough, the elimination strategy (3) is -PAC with
2.2 Mismatched Variances
In the case where , we rely on an -elimination strategy, described in Algorithm 1. For , denotes the empirical mean of the samples gathered from arm up to time . The algorithm is based on a non-uniform sampling strategy governed by the parameter which ensures that, at the end of every round , , and . The sampling schedule used here is thus deterministic.
If , the -elimination strategy using the exploration rate is -PAC on and satisfies, for every , for every ,
When , -elimination reduces, up to rounding effects, to the elimination procedure described in Section 3.2.1, for which Theorem 3.1 suggests an exploration rate of order . As the feasibility of this exploration rate when is yet to be established, we focus on Gaussian bandits with equal variances in the numerical experiments of Section 5.
The Bernoulli Case
We consider in this section the class of Bernoulli bandit models defined by
In this Section, we prove that for Bernoulli bandit models (Proposition 4.2). To do so, we first introduce a static strategy matching the lower bound of Theorem 2.1 in the fixed-budget case (Proposition 4.1). This strategy is reminiscent of the algorithm exhibited for Gaussian bandits in Section 3 and uses parameter-dependent non uniform sampling. This strategy is not directly helpful in practice but we show that it can be closely approximated by an algorithm using the uniform sampling strategy. In the fixed-confidence setting we similarly conjecture that little can be gained from using a non-uniform sampling strategy and propose an algorithm based on a non-trivial stopping strategy that is believed to match the bound of Theorem 2.2.
Let be defined by
For all , the static strategy that allocates samples to arm 1 , and recommends the empirical best arm, satisfies .
This result, proved in Appendix LABEL:proof:ConcExp, shows in particular that for every there exists a consistent static strategy such that
For all , .
In the specific case of Bernoulli distributions, there is a strong incentive to use uniform sampling: the quantities and introduced in Theorem 2.2 appear to be very close to and respectively. This fact is illustrated in Figure 1, on which we represent these different quantities, that are functions of the means of the arms, as a function of , for two fixed values of . Therefore, algorithms matching the bounds of Theorem 2.2 provide upper bounds on (resp. ) very close to (resp. ). In the fixed-budget setting, Lemma LABEL:lem:ConcExp shows that the strategy with uniform sampling that recommends the empirical best arm, satisfies , and matches the bound of Theorem 2.2 (see Remark LABEL:rem:Match in Appendix LABEL:proof:ConcExp). Hence, problem-dependent optimal strategy described above can be approximated by a very simple, universal algorithm.
Similarly, finding an algorithm for the fixed-confidence setting sampling the arms uniformly and matching the bound of Theorem 2.2 is a crucial matter. This boils down to finding a good stopping rule. In all the algorithms studied so far, the stopping rule was based on the difference of the empirical means of the arms. For Bernoulli arms, such a strategy can be analyzed with the tools provided in this paper: the algorithm stopping for such that with as in Theorem 3.1 is -PAC and its expected running time bounded by . Yet, Pinsker’s inequality implies that and this algorithm is thus not optimal with respect to Theorem 2.2. The approximation suggests that the loss with respect to the optimal error exponent is particularly significant when both means are close to 0 or 1. The stopping rule we propose to circumvent this drawback is the following:
Numerical Experiments and Discussion
The goal of this Section is twofold: to compare results obtained in the fixed-budget and fixed-confidence settings and to illustrate the improvement resulting from the adoption of the reduced exploration rate of Theorem 3.1.
In Figure 2, we consider two bandit models: the ’easy’ one is , (left) and the ’difficult’ one is , (right). In the fixed-budget setting, stars (’*’) report the probability of error as a function of . In the fixed-confidence setting, we plot both the empirical probability of error by circles (’O’) and the specified maximal error probability by crosses (’X’) as a function of the empirical average of the running times. Note the logarithmic scale used for the probabilities on the y-axis. All results are averaged on independent Monte Carlo replications. For comparison purposes, a plain line represents the theoretical rate which is a straight line on the log scale.
In the fixed-confidence setting, we report results for algorithms of the form (3) with for three different exploration rates . The exploration rate we consider are: the provably-PAC rate of Robbins’ algorithm (large blue symbols), the conjectured ’optimal’ exploration rate , almost provably -PAC according to Theorem 3.1 (bold green symbols), and the rate , which would be appropriate if we were to perform the stopping test only at a single pre-specified time (orange symbols). For each algorithm, the log probability of error is approximately a linear function of the number of samples, with a slope close to , where is the complexity. We can visualize the gain in sample complexity achieved by smaller exploration rates, but while the rate appears to guarantee the desired probability of error across all problems, the use of seems too risky, as one can see that the probability of error becomes larger than on difficult problems. To illustrate the gain in sample complexity when the means of the arms are known, we add in red the SPRT algorithm mentioned in the introduction along with the theoretical relation between the probability of error and the expected number of samples, materialized as a dashed line. The SPRT stops for such that .
If one compares on each problem the results for the fixed-budget setting to those for the best -PAC algorithm (in green), one can see that to obtain the same probability of error, the fixed-confidence algorithm needs an average number of samples of order at least twice larger than the deterministic number of samples required by the fixed-budget setting algorithm. This remark should be related to the fact that a -PAC algorithm is designed to be uniformly good across all problems, whereas consistency is a weak requirement in the fixed-budget setting: any strategy that draws both arm infinitely often and recommends the empirical best is consistent. Figure 2 shows that when the values of and are unknown, the sequential version of the test is no more preferable to its batch counterpart and can even become much worse if the exploration rate is chosen too conservatively. This observation should be mitigated by the fact that the sequential (or fixed-confidence) approach is adaptive with respect to the difficulty of the problem whereas it is impossible to predict the efficiency of a batch (or fixed-budget) experiment without some prior knowledge regarding the problem under consideration.
Elements of Proof
The cornerstone of the proof of all the lower bounds given in this paper is Lemma 6.1 which relates the probabilities of the same event under two different models to the expected number of draws of each arm. Its proof, which may be found in Appendix A, encapsulates the technical aspects of the change of distributions. denotes the number of draws of arm up to round and is the total number of draws of arm by some algorithm .
Without loss of generality, assume that the bandit model is such that . Consider any alternative bandit model in which and the event where is the arm chosen by algorithm . Clearly
using that . Optimizing over the possible model satisfying to make the right hand side of the inequality as large as possible gives the result, using moreover that for , it can be shown that .
Inequality (7) in Lemma 6.1 applied to yields
Taking the limsup (denoted by ) and letting go to zero, one can show that
Optimizing over the possible model satisfying to make the right hand side of the inequality as small as possible gives the result.
2 Proof of Theorem 3.1
Let be of the form , for some constants and . Lemma 6.2 yields
where . To upper bound the above probability by , at least for large values of (which corresponds to small values of ), it suffices to choose the parameters and such that
For , the left hand side tends to when goes to infinity, which is smaller than 1 for . Thus, for small enough, the desired inequality holds for and , which corresponds to the exploration rate of Theorem 3.1.
Conclusion
We provide distribution-dependent lower bounds for best-arm identification in the context of two-armed bandit models. These bounds involve information-theoretic quantities that reflect the typical causes of failure, which are different from those appearing in regret analysis. For Gaussian and Bernoulli bandit models, we exhibit matching algorithms showing that these bounds are (mostly) tight, highlighting relationships between the complexities of the fixed-budget and fixed-confidence settings. Our numerical experiments illustrate the significance of using appropriate exploration rates in the context of best arm(s) identification and we believe that Lemma 6.1 can be adapted to deal with more general -armed bandit scenarios.
These results suggest three practical implications for A/B testing. First, for Binary and Gaussian-like responses with matched variances it is reasonable to consider only tests—i.e., strategies using uniform sampling—rather than general sequential sampling strategies. Second, using a sequential stopping rule in this context is mostly of interest because it does not requires prior knowledge of the complexity of the problem. It should however not be expected to reduce the (average) running time of the experiment for a given probability of error. This leads to the third message regarding the utmost importance of using proper (i.e., provably -PAC but not too conservative) exploration rates when using a sequential stopping rule.
We thank Sébastien Bubeck for fruitful discussions during the visit of the first author at Princeton University. This work was supported by the ANR-2010-COSI-002 grant of the French National Research Agency.
References
Appendix A Proof of Lemma 6.1: Changes of Distributions
Under the identifiability assumption, there exists a common measure such that for all , for all has a density with respect to .
Let be a bandit model, and consider an alternative bandit model . are the densities of respectively and one can introduce the log-likelihood ratio of the observations up to time under an algorithm :
Let be any stopping time with respect to . For every event (i.e. such that ),