Optimistic Initial Values
By initializing action values far above realistic rewards, an agent is naturally disappointed every time it tries an action, systematically driving it to sample all untried alternatives.
Why Does This Exist?
In reinforcement learning, a standard greedy action-selection policy () chooses whichever action currently has the highest estimated value. If all action-value estimates are initialized to zero (), the agent falls victim to an immediate lock-in trap: the first arm it samples that produces any positive reward (e.g., ) instantly becomes the highest-rated option. Untried arms remain at , so the greedy agent exploits that mediocre arm indefinitely, never discovering that a neighboring arm yields .
Without an active exploration mechanism, greedy agents suffer severe lock-in and catastrophic regret. While -greedy prevents this by injecting random action selection, it carries a persistent tax: the agent continues pulling suboptimal arms at a fixed random rate forever, unless a complex decay schedule is hand-tuned.
Optimistic initial values provide a simple, deterministic exploration technique for stationary tabular problems. By deliberately setting the starting estimates well above any achievable reward (), every action taken produces an outcome lower than expected. This systematic disappointment depresses the chosen arm's estimate below the pristine estimates of untried arms, naturally compelling the greedy policy to sample every available action before repeating any of them.
Think of It Like This
The Hyper-Optimistic Restaurant Critic
Imagine a food critic who moves to a new city and starts with an unshakable assumption: every restaurant in this city is a 5-star culinary masterpiece until proven otherwise.
On Monday evening, seeking dinner, the critic visits Restaurant A (expected rating: 5.0 stars). The meal is respectable—a 3-star dinner. Because 3 stars is lower than their 5.0-star expectation, the critic feels disappointed and lowers Restaurant A's mental rating to 4.2 stars.
On Tuesday evening, the critic asks: "Where is the best place to eat?" Restaurant A is now rated 4.2 stars, but Restaurants B, C, and D are still assumed to be 5.0 stars. Being purely greedy (always picking the highest-rated venue), the critic walks past Restaurant A and dines at Restaurant B. Restaurant B turns out to be a greasy spoon that serves a 1-star meal, plunging its rating to 3.8 stars.
On Wednesday and Thursday, the critic visits Restaurants C and D because untried eateries still hold the pristine 5.0-star rating.
The critic never needs to flip a coin or pick restaurants at random. Their initial optimism guarantees that every early meal brings disappointment, automatically driving them to tour every eatery in town before settling down on the true best spot.
Where the analogy stops: In real life, restaurants change owners, hire new chefs, or overhaul menus over time (non-stationarity). If Restaurant B hires a Michelin-starred chef a year later, the critic—whose rating for Restaurant B is permanently parked at 1.8 stars—will never step inside again. Optimism only burns once; it does not rekindle when the environment changes.
How It Actually Works
The Mechanism of Systematic Disappointment
Let denote the discrete action set, and let rewards be bounded such that .
The agent maintains an action-value estimate for each action . At step , a purely greedy policy selects the action with the maximum estimated value:
When ties occur, they are broken deterministically (e.g., choosing the lowest index). After executing action and observing reward , the estimate is updated via a constant step-size parameter :
where:
- is the prior value estimate for the selected action.
- is the observed scalar reward.
- is the prediction error (surprise).
- is the constant step-size parameter (learning rate).
Under optimistic initialization, the initial values are configured such that:
Because every realized reward satisfies , the prediction error on the initial selection of any arm is guaranteed to be negative:
The chosen arm's estimate immediately drops below . Meanwhile, all untested arms retain their optimistic ceiling of . At step , the greedy rule strictly prefers the untried actions over the sampled action.
Expanding the constant step-size update rule recursively shows how initial optimism decays over selections of an action:
The initial value acts as a prior whose influence decays at an exponential rate of . As , , eliminating the initial bias and allowing to converge to the true expected reward .
Worked numerical example
Consider a 3-armed bandit () with true reward means , , and . Let the learning rate be , and initialize all arms optimistically to . When multiple arms share the maximal value, the tie is broken by choosing the smallest arm index.
-
Step 1 ():
- Current estimates: .
- Selection: All three arms are tied at . Smallest index selects Arm 1 ().
- Observed reward: .
- Prediction error: .
- Update:
- New estimates: .
- Outcome: Disappointment lowers Arm 1 below the untried arms.
-
Step 2 ():
- Current estimates: .
- Selection: Arms 2 and 3 are tied at . Smallest index selects Arm 2 ().
- Observed reward: .
- Prediction error: .
- Update:
- New estimates: .
- Outcome: Arm 2 drops to . Untried Arm 3 is now uniquely highest.
-
Step 3 ():
- Current estimates: .
- Selection: Arm 3 uniquely maximizes (), so .
- Observed reward: .
- Prediction error: .
- Update:
- New estimates: .
- Outcome: Every arm has now been sampled once without any random exploration.
-
Step 4 ():
- Current estimates: .
- Selection: Arm 1 has the highest estimate () because it suffered the smallest disappointment (). The agent selects .
- Observed reward: .
- Prediction error: .
- Update:
- New estimates: .
- Outcome: Arm 1 drops to , falling below Arm 2 () and Arm 3 (). On Step 5, the greedy policy naturally switches back to Arm 2, cycling through multiple passes across all arms until value estimates converge to the true reward range.
Code
def simulate_greedy_bandit( true_means: list[float], initial_q: float, steps: int = 12, alpha: float = 0.2,) -> tuple[list[int], list[float]]: """Simulates a greedy bandit agent with given initial Q-values.""" num_arms = len(true_means) q_values = [initial_q] * num_arms action_history: list[int] = []
for _ in range(steps): # Pure greedy action selection (break ties by lowest index) best_arm = 0 best_val = q_values[0] for arm in range(1, num_arms): if q_values[arm] > best_val: best_val = q_values[arm] best_arm = arm
# Observe reward and update value estimate reward = true_means[best_arm] q_values[best_arm] += alpha * (reward - q_values[best_arm]) action_history.append(best_arm)
return action_history, [round(v, 3) for v in q_values]
# Arm 0 is mediocre (0.2), Arm 1 is optimal (0.8), Arm 2 is poor (0.1)true_means = [0.2, 0.8, 0.1]
# 1. Standard zero initialization (Q0 = 0.0) -> Trapped on mediocre Arm 0zero_actions, zero_q = simulate_greedy_bandit(true_means, initial_q=0.0)
# 2. Optimistic initialization (Q0 = 5.0) -> Explores all arms systematicallyopt_actions, opt_q = simulate_greedy_bandit(true_means, initial_q=5.0)
print(f"Zero-init actions: {zero_actions}")# -> Zero-init actions: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print(f"Zero-init final Q: {zero_q}")# -> Zero-init final Q: [0.186, 0.0, 0.0]
print(f"Optimistic actions: {opt_actions}")# -> Optimistic actions: [0, 1, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]
print(f"Optimistic final Q: {opt_q}")# -> Optimistic final Q: [2.166, 2.52, 2.107]Watch Out For
Failure in Non-Stationary Environments
Optimistic initial values only produce transient exploration. Once the initial optimistic bias decays () and all arms have been sampled multiple times, the mechanism completely ceases to drive exploration.
If the environment is non-stationary—meaning reward distributions drift over time or a previously weak arm becomes the new optimal option later in the run—a purely greedy agent will never detect the shift. Because its estimate for that arm is already depressed and initial optimism has vanished, the agent stays permanently locked onto its historical favorite.
The Fix: Never use optimistic initial values as the sole exploration mechanism in non-stationary problems. Combine optimism with continuous exploration strategies such as -greedy with a persistent floor, Upper Confidence Bound (UCB) with sliding observation windows, or discounted tracking updates.
Excessive Exploration from Oversized Initial Values
If initial values are set unrealistically high relative to the step size , the optimistic bias takes an exorbitant number of steps to decay. The agent will repeatedly sample obviously terrible arms across hundreds of rounds simply because their estimates remain artificially inflated well above reality.
The Fix: Set only modestly above the known upper bound of rewards (e.g., to ). Avoid arbitrarily huge initializations like unless accompanied by a proportionally large early learning rate.
The Quick Version
- Core Mechanism: Action-value estimates are initialized to an optimistic ceiling () well above any achievable reward.
- Exploration via Disappointment: Every trial produces negative surprise (), depressing that action's estimate and forcing a greedy policy () to try untried alternatives.
- Deterministic Efficiency: Unlike -greedy, exploration is structured and non-random, eliminating wasted pulls on random actions once estimates converge.
- Transient Exploration Only: Initial optimism burns away once tested; it cannot adapt to non-stationary environments where optimal arms drift over time.