11  Data 102 Discussion 11: Regret of Explore-Then-Commit

11.0.1 Contact Information

Name Wesley Zheng
Pronouns He/him/his
Email wzheng0302@berkeley.edu
Discussion Wednesdays, 11–12 PM @ Wheeler 224
Office Hours Tuesdays, 9–10 AM & 11–12 PM @ Gateway B1040

Contact me by email at ease — I typically respond within a day or so!


11.1 Regret of Explore-Then-Commit

Now, we will analyze the regret of the Explore-then-Commit algorithm for the multi-armed-bandit (MAB) problem. We consider a stochastic MAB problem with a set of \(K=2\) arms \(\mathcal{A} =\{1,2\}\). Recall that each arm \(A \in \mathcal{A}\) is associated with a reward distribution \(X_A \sim \mathbb{P}_A\), with corresponding mean \(\mu_A = \mathbb{E}\left[X_A\right]\). We will assume throughout this problem that the first arm has higher average reward, i.e. \(\mu_1 > \mu_2\). At each round \(t=1,\ldots,n\) our algorithm chooses an arm \(A_t\in \mathcal{A}\) and receives a corresponding reward \(X_{A_t}^{(t)}\sim \mathbb{P}_{A_t}\), independent of all previous rewards.

If we knew arm 1 has higher average reward, we would choose \(A_t = 1\) each round in order to maximize the expected total reward. In practice, however, we do not know which arm is better since the means \(\{\mu_1, \mu_2\}\) are unknown. The expected reward of our algorithm will always be less than \(n\mu_{1}\), and we quantify the price we pay for not knowing the better arm via the expected regret \[ r_n := n\mu_{1} - \mathbb{E}\left[\sum_{t=1}^n X_{A_t}^{(t)}\right] \] In this problem we analyze the regret of the explore-then-commit (ETC) algorithm, which is outlined as follows:

Explore-then-Commit (ETC) Algorithm

Input: Number of initial pulls \(c\) per arm

  1. For \(t=1,\ldots,cK\):
    • Choose arm \(A_t=(t \ \text{mod} \ K)+1\)
  2. Let \(\hat{A}\in \{1,\dots, K\}\) denote the arm with the highest average reward so far
  3. For \(t=cK+1, cK+2, \ldots, n\):
    • Choose arm \(A_t=\hat{A}\)

As we can observe from the algorithm above, ETC proceeds in two phases. In the exploration phase, each arm \(A \in \mathcal{A}\) is pulled \(c\) times in order to produce an estimate \(\hat\mu_A = \frac{1}{c}\sum_{t\le cK : A_t = A}X_A^{(t)}\) of the mean reward for that arm. In the commit phase, i.e. for every \(t > cK\), we choose \(A_t = \hat{A}\), where \(\hat{A} := \operatorname*{arg\,max}_{A\in \mathcal{A}}\,\hat{\mu}_A\) is the apparent best arm at the end of the exploration phase. In the first part of our analysis, we evaluate the probability that we incorrectly identify arm \(2\) as the best arm, i.e. \(\mathbb{P}(\hat{A} = 2)\).


11.1.1 (a)

Bounding the Chance of Selecting a Sub-optimal Arm

Assume each reward is in the unit interval \([0, 1]\), i.e. \(0\le X_A\le 1\) for \(A\in \{1,2\}\). Show that \[ \mathbb{P}\left (\hat{A} = 2\right) \le \exp\left(-\frac{c\Delta^2}{2} \right), \] where \(\Delta = \mu_{1} - \mu_2\).

Answer

We start by expanding the LHS using the following steps: \[ \begin{aligned} \mathbb{P}[\hat{A} = 2] &= \mathbb{P}[\hat{\mu}_2 \geq \hat{\mu}_1] \\ \mathbb{P}[\hat{A} = 2] &= \mathbb{P}[\hat{\mu}_2 - \hat{\mu}_1 \geq 0] \\ \mathbb{P}[\hat{A} = 2] &= \mathbb{P}[(\hat{\mu}_2 - \hat{\mu}_1) - \mathbb{E}[\hat{\mu}_2 - \hat{\mu}_1] \geq \Delta] \end{aligned} \] Line 1 uses the fact that arm 2 is selected when the observed sample mean of rewards from arm 2 is greater than that of arm 1 (i.e. \(\hat{\mu}_2 \geq \hat{\mu}_1\)). Line 3 uses the fact that \(\Delta = \mu_1 - \mu_2\), since we know arm 1 has the higher true mean. From here, observe that we can apply Hoeffding’s inequality since \(\hat{\mu}_2 \geq \hat{\mu}_1\) represents the average of \(c\) independent random variables. The last step before directly applying Hoeffding’s inequality is to find the bounds of each random variable. Since the distribution of rewards for each arm is bounded between [0, 1], then their difference is bounded between [-1, 1]. Therefore, by Hoeffding’s Inequality for bounded random variables, we find that: \[ \begin{aligned} \mathbb{P}[\hat{A} = 2] &\leq \exp\left( -\frac{2c \Delta^2}{(1 - (-1))^2} \right) \\ \mathbb{P}[\hat{A} = 2] &\leq \exp\left( -\frac{c \Delta^2}{2} \right) \end{aligned} \]


11.1.2 (b)

Regret Decomposition

Let \(N_n(2)\) denote the number of times arm \(2\) has been pulled, up to and including time \(n\). Show \[ r_n = \Delta \mathbb{E}[N_n(2)] \] Hint: Start from the following: \[ \begin{aligned} r_n &:= n\mu_{1} - \mathbb{E}\left[\sum_{t=1}^n X_{A_t}^{(t)}\right] = \mathbb{E}\left[\sum_{t=1}^n \left(\mu_{1} - X_{A_t}^{(t)}\right) \right] \\ & = \mathbb{E}\left[\sum_{t=1}^n \mathbb{I}\{A_t = 1\}\left(\mu_{1} - X_{1}^{(t)}\right) \right] +\mathbb{E}\left[\sum_{t=1}^n \mathbb{I}\{A_t = 2\}\left(\mu_{1} - X_{2}^{(t)}\right) \right]. \end{aligned} \] Note also that for all \(t\), \(A_t\) is independent of \(X_{A}^{(t)}\) for \(A\in \{1,2\}\).

Answer

Working from the hint, we have that: \[ \begin{aligned} r_n &= \mathbb{E}\left[\sum_{A\in \mathcal{A}} \sum_{t=1}^n \mathbb{I}\{A_t = A\}\left(\mu_{A^*} - X_{A}^{(t)}\right) \right] \\ &= \sum_{A\in \mathcal{A}} \sum_{t=1}^n\mathbb{E}\left[ \mathbb{I}\{A_t = A\}\left(\mu_{A^*} - X_{A}^{(t)}\right) \right] && \text{by linearity of expectation} \\ &= \sum_{A\in \mathcal{A}} \sum_{t=1}^n\mathbb{E}\left[ \mathbb{I}\{A_t = A\} \right]\mathbb{E}\left[\mu_{A^*} - X_{A}^{(t)} \right] && \text{by independence} \\ &= \sum_{t=1}^n\mathbb{E}\left[ \mathbb{I}\{A_t = 1\} \right]\mathbb{E}\left[\mu_{1} - X_{1}^{(t)} \right] \\ &+ \sum_{t=1}^n\mathbb{E}\left[ \mathbb{I}\{A_t = 2\} \right]\mathbb{E}\left[\mu_{1} - X_{2}^{(t)} \right]&& \text{by splitting up the first summation}\\ &= 0 + \sum_{t=1}^n\mathbb{E}\left[ \mathbb{I}\{A_t = 2\} \right]\Delta\\ &= \Delta \mathbb{E}\left[ \sum_{t=1}^n \mathbb{I}\{A_t = 2\} \right]\\ &= \Delta \mathbb{E}[N_n(2)] \end{aligned} \]


11.1.3 (c)

Finding the Expected number of Sub-optimal Pulls

Show that if \(n > 2c\), then: \[ \mathbb{E}[N_n(2)]=c+(n-2c)\mathbb{P}\left (\hat{A} = 2\right) \]

Answer

From the ETC algorithm, we know that that every arm is deterministically pulled \(c\) times during the “exploration” phase, which is during the first \(cK\) rounds. Afterwards, an arm is only pulled if it is the one we committed to. Therefore, we can express \(m\) in the following way: \[ \begin{aligned} N_n(2) &= \text{\# Pulls of Arm 2 in Exploration} + \text{\# Pulls of Arm 2 after Committing} \\ N_n(2) &= c + (n - cK)\mathbb{I}\{ \hat{A} = A \} \end{aligned} \] Taking the expectation on both sides and using the fact that \(K = 2\), we conclude that \[ \mathbb{E}[N_n(2)]=c+(n-2c)\mathbb{P}\left (\hat{A} = 2\right) \]


11.1.4 (d)

Bounding the Regret of ETC

Show that: \[ r_n \le \Delta\left( c+(n-2c)\exp\left(-\frac{c\Delta^2}{2} \right)\right) \]

Answer

From Part (b), we showed that \(R_n = \Delta \mathbb{E}[N_n(2)]\).

Plugging in the result from Part (c), we have that \[ r_n = \Delta \left[c+(n-2c)\mathbb{P}\left (\hat{A} = 2\right)\right] \] Finally, using the upper-bound derived in Part (a), we plug in for \(\mathbb{P}\left(\hat{A} = 2 \right)\) to get the final result: \[ r_n \le \Delta\left( c+(n-2c)\exp\left(-\frac{c\Delta^2}{2} \right)\right) \]


11.1.5 (e)

Analyzing the Regret of ETC

Suppose you knew the sub-optimality gap \(\Delta\). Solve for a value of \(c\) which guarantees that: \[ \exp\left(-\frac{c\Delta^2}{2} \right)\le \frac{1}{n} \] For this number of exploratory pulls \(c\), what is the upper bound on the regret from Part (d)? Your answer should be in terms of \(n\) and \(\Delta\). Does this bound grow linearly in \(n\), or does it do better (i.e. is it sublinear)?

Answer

Solving for \(c\) gives \[ c = \frac{2\log n}{\Delta^2} \] Plugging this into our regret bound from Part (e) gives \[ r_n \leq \frac{2\log n}{\Delta} + \Delta \] This bound is sublinear in \(n\) due to the \(\log n\) term. However, in practice, we cannot assume that we know \(\Delta\).