The interview problem

Practice prompt

Work through a simple upper-confidence selection rule and contrast it with always choosing the highest observed mean.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume stationary bounded rewards and one action per round. After initializing each arm, score it using empirical mean plus an uncertainty bonus, for example sqrt(2 log t / n) in a common UCB1 convention. Select the largest score, observe its reward and update only that arm. This is a toy independent-action setting, not an immediate prescription for a user-facing experiment.

2. Trace the design or derivation

Initialize arms
  → calculate mean plus bonus
  → choose arm
  → observe reward
  → update count

The logarithm uses total decision time while the denominator uses that arm's observation count. If rewards are delayed, counting a pending pull as a fully observed sample prematurely shrinks uncertainty. A production adaptation must explicitly distinguish selected actions, observed outcomes and rewards still in flight.

3. Calculate the example

At t=100, arm A has mean 0.6 from 80 pulls and arm B mean 0.5 from 20. Bonuses are approximately 0.3393 and 0.6786, giving scores 0.9393 and 1.1786. B is selected because it remains less explored.

4. Failure cases and trade-offs

Nonstationary rewards, delayed observations and interference violate the simple assumptions. Exploration incurs short-term cost; a greedy policy avoids that immediate cost but can lock onto early noise. UCB scores can exceed the reward range because they are selection indices, not calibrated probabilities.

5. Validation, follow-ups and self-review

Verify initialization avoids division by zero and simulate a known two-arm environment. Follow-up: what changes with delayed rewards or context? Self-review: explain the reward assumptions and why an index above one is not a probability error.

Sources and related practice

Technical reference: homes.di.unimi.it — UCB1 for bounded stationary bandit rewards.

Source publication/update: 2002. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Distinguish prediction from causal effects; Design learning from delayed conversion labels.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.