Skip to content
AI360Xpert
Beta

Sample Complexity of Exploration

Sample complexity counts how many environment steps an agent must pay before it can promise a near-optimal policy with high confidence.

Samples buy confidence and confidence buys a near-optimal policy: 236,120 paid steps turn 40 state-action pairs known at 95 percent confidence into a policy within 0.5 of optimal.
Samples buy confidence and confidence buys a near-optimal policy: 236,120 paid steps turn 40 state-action pairs known at 95 percent confidence into a policy within 0.5 of optimal.

Why Does This Exist?

Every exploration trick eventually faces the same awkward question: how many tries is enough? You can run epsilon-greedy for a million steps and still not know whether your policy is good or you just got lucky. Sample complexity answers that question with a number.

If you have not met these ideas yet, start here. An MDP says what the world is: states, actions, rewards, transitions, and a horizon HH over which returns add up. The exploration versus exploitation tradeoff says why learning hurts: you must try poorly understood actions to find out they are poor, and each try costs a real environment step. This page turns that pain into a budget: given SS states, AA actions, horizon HH, an accuracy target ϵ\epsilon (epsilon), and a failure tolerance δ\delta (delta), how many steps before the agent can promise a near-optimal policy?

This page covers the PAC counting argument plus the RMAX and E3 intuition behind it. It does not teach the MDP itself or any specific exploration bonus; those live on the two prerequisite pages above.

Think of It Like This

The new-city food critic

You move to a city with 40 restaurants and promise your editor a review that is within half a star of the truth, and you want to be 95 percent sure you are right.

One visit proves nothing, because any single meal could be a fluke. So you set a rule: every restaurant gets repeat visits until your estimate stops wobbling, then you publish. More restaurants mean more visits. Tighter accuracy means far more visits. Higher confidence means a few extra visits on top.

RMAX is the critic who assumes every unvisited restaurant might be amazing, which is exactly what drags them through the door. E3 is the critic who does all the visiting first and writes the final guide only after every place is known.

Where the analogy stops: restaurants do not change their menu because you reviewed them, but an MDP keeps responding to your behavior, so the agent must also handle sequential effects over a horizon, not just average isolated meals.

How It Actually Works

PAC stands for Probably Approximately Correct. A policy π\pi is ϵ\epsilon-optimal when its value V(π)V(\pi) sits within ϵ\epsilon of the best achievable value V\*V^{\*}, meaning V(π)≥V\*−ϵV(\pi) \ge V^{\*} - \epsilon. The 1−δ1 - \delta part is the confidence: over the randomness of exploration, the promise holds with probability at least 1−δ1 - \delta. So (ϵ,δ)=(0.5,0.05)(\epsilon, \delta) = (0.5, 0.05) reads as "within 0.5 of optimal, 95 times out of 100." Smaller ϵ\epsilon means pickier. Smaller δ\delta means surer.

Why each symbol charges you samples

SS (states) and AA (actions) set the number of things to learn: S×AS \times A state-action pairs, each needing its own visits. HH (horizon) stretches every estimate, because one bad transition early can corrupt a whole HH-step return, so longer episodes demand more repeats per pair. The 1/ϵ21/\epsilon^2 term is the cruel one and comes from concentration: averaging mm noisy samples shrinks the estimation error like 1/m1/\sqrt{m}, so demanding half the error needs four times the samples. The log⁡(1/δ)\log(1/\delta) term is the bargain of the family: certainty is bought with a logarithm, so going from 95 to 99 percent confidence adds a small multiplier, not a doubling.

RMAX and E3 in one paragraph each

RMAX (Brafman and Tennenholtz, 2002) splits every pair into known or unknown. Unknown pairs get an optimistic fantasy value, the best return imaginable, which pulls the planner toward them automatically. The agent explores precisely because its model lies to it in a useful direction, and once a pair has enough visits it flips to known and the fantasy ends. E3 (Kearns and Singh, 2002) is more explicit: it runs a balanced wandering phase until its statistics say the world is known, then it freezes exploration and exploits the learned model. Both share the same moral. Exploration costs samples because unknown pairs must each be visited enough times, and optimism is just the engine that makes the agent pay up.

Worked bound instantiation

Here is one concrete instantiation so you can feel the sizes. It uses an illustrative canonical per-pair threshold in the RMAX and PAC-MDP style (Hoeffding averaging plus a union bound over all pairs, after Strehl, Li, and Littman, 2009):

m=⌈H22ϵ2ln⁡(2SAδ)⌉m = \left\lceil \frac{H^2}{2\epsilon^2} \ln\left(\frac{2SA}{\delta}\right) \right\rceil

with S=10S = 10 states, A=4A = 4 actions, H=20H = 20 steps, ϵ=0.5\epsilon = 0.5, and δ=0.05\delta = 0.05. Step by step:

  1. Count the pairs: S×A=10×4=40S \times A = 10 \times 4 = 40.
  2. The confidence price: ln⁡(2SA/δ)=ln⁡(1600)≈7.38\ln(2SA/\delta) = \ln(1600) \approx 7.38.
  3. The accuracy price: H2/(2ϵ2)=400/0.5=800H^2 / (2\epsilon^2) = 400 / 0.5 = 800.
  4. Visits per pair: m=⌈800×7.38⌉=5,903m = \lceil 800 \times 7.38 \rceil = 5{,}903.
  5. Total learning bill: 40×5,903=236,12040 \times 5{,}903 = 236{,}120 environment steps.

Now halve the accuracy target to ϵ=0.25\epsilon = 0.25 and everything else stays put. The accuracy price becomes 400/0.125=3,200400 / 0.125 = 3{,}200, so m=⌈3,200×7.38⌉=23,609m = \lceil 3{,}200 \times 7.38 \rceil = 23{,}609 per pair and 944,360944{,}360 steps in total. Twice as picky, four times the bill. That is the 1/ϵ21/\epsilon^2 blowup in plain numbers.

Treat the formula as a teaching shape, not a quoted theorem constant: real RMAX and PAC-MDP statements carry extra horizon factors and tighter constants depending on discounted versus finite-horizon setup. The scaling lesson survives every version: linear in SS and AA, quadratic in 1/ϵ1/\epsilon, logarithmic in 1/δ1/\delta, and steep in HH.

Code

This short script recomputes the worked example, so you can change the targets and watch the bill move.

import math

def known_threshold(num_states, num_actions, horizon, eps, delta):    """Illustrative canonical per-pair visit threshold (RMAX/PAC-MDP style)."""    log_term = math.log(2 * num_states * num_actions / delta)    return math.ceil((horizon**2 / (2 * eps**2)) * log_term)

S, A, H, EPS, DELTA = 10, 4, 20, 0.5, 0.05m = known_threshold(S, A, H, EPS, DELTA)print(f"log term: {math.log(2 * S * A / DELTA):.4f}")print(f"visits per pair: {m}")print(f"total steps: {S * A * m}")
m_tight = known_threshold(S, A, H, 0.25, DELTA)print(f"halved eps per pair: {m_tight}")print(f"halved eps total: {S * A * m_tight}")
# -> expected output:log term: 7.3778visits per pair: 5903total steps: 236120halved eps per pair: 23609halved eps total: 944360

Watch Out For

Demanding half the error without budgeting four times the samples

The symptom: you tighten ϵ\epsilon from 0.5 to 0.25, keep the same training budget, and conclude exploration stopped working when the policy still wobbles. Nothing broke. Averaging cuts error like 1/m1/\sqrt{m}, so the bill grows with 1/ϵ21/\epsilon^2 and your 236,120-step budget now needs 944,360 steps. Before blaming the algorithm, recompute mm for the new ϵ\epsilon and check whether you actually paid for the accuracy you asked for.

Reading a regret bound as a PAC promise

The symptom: a paper reports sublinear regret and you quote it as "needs only NN steps to be ϵ\epsilon-optimal," then wonder why no fixed NN appears. Regret totals the cost along the whole learning run, while PAC counts how many steps fall outside ϵ\epsilon-optimality. They are cousins, not twins. If you need a stopping rule ("when can I ship this policy?"), reach for the PAC statement with its explicit ϵ\epsilon and δ\delta, not the regret curve.

The Quick Version

  • Sample complexity is the number of environment steps before an agent can promise an ϵ\epsilon-optimal policy with probability at least 1−δ1 - \delta.
  • The bill grows with more states, more actions, and longer horizons, quadratically with 1/ϵ1/\epsilon, and only logarithmically with 1/δ1/\delta.
  • RMAX explores by treating unknown pairs as optimistically wonderful, which pulls the planner toward them until visits make them known.
  • E3 separates the job into two phases: wander in a balanced way until the world is known, then stop exploring and exploit the learned model.
  • In the worked instantiation with 10 states, 4 actions, horizon 20, ϵ=0.5\epsilon = 0.5, and δ=0.05\delta = 0.05, each pair needs 5,903 visits for a total of 236,120 steps, and halving ϵ\epsilon quadruples the total to 944,360.