Markov Decision Processes and Reinforcement Learning

Learn how an agent can make a sequence of good decisions when the outcome of each action is uncertain. Model such problems as Markov decision processes, express the value of states and actions with Bellman equations, and compute optimal policies with value iteration and policy iteration. Then drop the assumption that the model is known: estimate values from experience with model-based learning and temporal-difference learning, learn to act with Q-learning, balance exploration against exploitation, and see how features let Q-learning handle large problems. One small delivery-robot example, worked with real numbers, runs through the whole material.

IntermediateLesson 8 of 10 in Artificial Intelligence Course

What you will learn

  1. Describe a decision problem with uncertain outcomes in terms of states, actions, transition probabilities and rewards, and compare behaviors by their expected discounted reward.
    • Describe the parts of a Markov decision process
      Name the states, actions, transition model and reward function of an MDP, read them from a table, and explain the Markov property the model relies on.
    • Compare policies using discounted returns
      Define policies and discounted returns, compute a return for a sequence of rewards, and explain how the discount factor and the reward per step change which behavior is best.
    • Formulate a real problem as an MDP
      Turn a described situation into states, actions, probabilities, rewards and a discount factor, choose a state that satisfies the Markov property, and design rewards that express the real objective.
  2. Define the value of a state and of a state–action pair, for a given policy and for optimal behavior, and use Bellman equations to link each value to the values of the states that can follow.
    • Define state values and Q-values
      Explain what V-values and Q-values measure, relate optimal values and optimal policies, and read a policy from Q-values.
    • Write and check Bellman equations
      Derive the Bellman equations for a fixed policy and for optimal values, solve a small policy-evaluation system by hand, and check whether given values satisfy the equations.
  3. Compute the values of a policy and an optimal policy when the transition model and rewards are known, using policy evaluation, value iteration and policy iteration.
    • Evaluate a fixed policy
      Compute the values of a given policy exactly or iteratively and explain what the intermediate values mean.
    • Compute optimal values with value iteration
      Apply the value-iteration update by hand, explain what the values mean after k iterations, decide when to stop, and extract the policy.
    • Find optimal policies with policy iteration
      Alternate policy evaluation and policy improvement until the policy stops changing, and compare policy iteration with value iteration.
  4. Explain how reinforcement learning differs from planning, and estimate a model or a policy's values from observed transitions with model-based learning, direct evaluation and temporal-difference learning.
    • Explain the reinforcement learning setting and learn a model
      Describe what a learning agent knows and observes, distinguish passive from active learning, and build and use an estimated model from counts.
    • Estimate values with direct evaluation and temporal-difference learning
      Estimate a fixed policy's values by averaging sampled returns and by temporal-difference updates, and explain why state values alone cannot choose actions without a model.
  5. Learn optimal behavior without a model using Q-learning, balance trying new actions against using the best known ones, and extend Q-learning to large problems with features.
    • Learn optimal Q-values with Q-learning
      Apply the Q-learning update to observed transitions, explain why it learns the optimal policy while behaving differently, and state when it converges.
    • Balance exploration and exploitation
      Explain why a learning agent must sometimes try actions that look worse, and use epsilon-greedy action selection, exploration functions and confidence bounds to do so.
    • Generalize with approximate Q-learning
      Represent Q-values as a weighted sum of features, update the weights from experience, and explain what generalization gains and what it can break.

Reinforcement Learning study guide

5 chapters

1

Model sequential decisions as Markov decision processes

A useful decision model describes both what an agent controls and what can happen by chance. A delivery robot can choose to work or charge, but it cannot choose whether its battery survives another job. States, transition probabilities, and rewards make this distinction precise. Policies then describe how to act across many possible runs, while discounted returns express how much the agent values rewards now and later.

1.1 Describe an agent's states and choices

A Markov decision process, or MDP, describes repeated decisions when actions can have uncertain outcomes. The agent observes its current state, chooses an available action, receives a reward, and moves to a new state. These four parts describe one transition; a sequence of transitions describes a run.

Read a transition model

The state set is S, and A(s) lists the actions allowed in state s. The transition model T(s,a,s′)=P(s′∣s,a) gives the chance of reaching s′ after taking a in s. For each state–action pair, all these probabilities are nonnegative and sum to 1. The reward R(s,a,s′) belongs to that transition. A negative reward represents a cost or penalty.

Consider a delivery robot with states High battery, Low battery, and Dead. Dead ends the episode. Its model is:

StateActionNext state and probabilityReward
HighWorkHigh: 0.7; Low: 0.3+4 for either outcome
HighChargeHigh: 10
LowWorkLow: 0.6; Dead: 0.4+4 if Low; −10 if Dead
LowChargeHigh: 10

The two Work rows each sum to 1. For Work in Low, the expected immediate reward is 0.6(4)+0.4(−10)=−1.6. This average is useful for planning, but an actual attempt earns either 4 or −10. Choosing Work chooses the distribution; it does not choose the successful outcome.

Put the relevant past into the state

The Markov property means that the current state and action contain the information needed to predict the next state:

P(st+1∣st,at,past)=P(st+1∣st,at).

The world may have a long history. That history matters through the variables included in the current state. A robot's location alone may be insufficient if its battery determines whether a job succeeds. Including the battery level lets the model distinguish situations with different risks.

A standard MDP assumes the agent observes the state exactly. If important parts of the state are hidden, the agent needs a belief about possible states; that leads to a partially observable MDP, or POMDP.

Recognize endings and random movement

A terminal state has value 0 because no rewards follow it. The reward on entering it still counts: the robot receives −10 on its last transition into Dead. Episodic tasks end at a terminal state; continuing tasks, such as ongoing temperature management, need no terminal state.

In a grid world, an intended move can succeed with probability 0.8 and slip in either perpendicular direction with probability 0.1 each. An attempted move into a wall leaves the agent in place. Probabilities of outcomes that reach the same square must be combined.

Deterministic transitions are a special case: one successor has probability 1. For a known start and a suitable goal-reaching task, a fixed plan can suffice. With uncertain outcomes, a policy specifies how to respond in whichever state actually occurs. Some texts write rewards as R(s) or R(s,a); check the timing convention before translating a formula.

Key Takeaways

  • A transition model assigns probabilities to next states for each state–action pair.
  • The state must retain the information needed to predict outcomes and rewards.
  • A terminal state has zero future value; its entry reward still counts.
  • A policy supplies an action for each state the agent may encounter.

1.2 Compare rewards across time

A policy describes how the agent acts. A deterministic stationary policy π(s) chooses one action for each state and keeps that choice over time. For the robot, "Work when High, Charge when Low" is such a policy. A stochastic policy π(a∣s) assigns probabilities to the available actions.

Calculate a return

The discounted return combines rewards across a run:

U=r0+γr1+γ2r2+⋯ .

The first transition earns r0 with weight 1. Each later reward receives one more factor of the discount γ. For rewards −1, −1, −1, and +10 followed by termination, using γ=0.9 gives

U=−1−0.9−0.81+10(0.729)=4.58.

With γ=0.5, the same run gives −1−0.5−0.25+10(0.125)=−0.5. The delayed gain loses much of its weight. Discounting can represent a preference for earlier rewards, or the chance that the process continues to another step.

A policy is judged by its expected return, averaging over its possible runs. One lucky run does not establish that a policy is good. An optimal policy π∗ gives the largest expected return from every state. A finite discounted MDP has an optimal policy that is deterministic and stationary.

Keep an infinite future finite

For bounded rewards and 0≤γ<1, the geometric series bounds every return. If ∣rt∣≤Rmax⁡, then

∣U∣≤Rmax⁡1−γ.

The robot's largest reward magnitude is 10, so γ=0.9 gives ∣U∣≤100. Since its largest positive reward is 4, its return also cannot exceed 4/(1−0.9)=40. These are bounds, not claims that the robot can achieve them.

The quantity 1/(1−γ) is a rough effective horizon: about 10 steps for γ=0.9. It is not a cutoff. A reward 10 steps later still receives weight 0.910≈0.35. Undiscounted continuing tasks need special care: repeated positive rewards can make returns infinite. A fixed finite horizon makes the sum finite; episodic models also need well-behaved episode lengths for finite expected values.

Let time and step rewards affect decisions

With a deadline, the best action can depend on the time left. Consider a machine in Worn condition. Run earns 6 and leaves it Worn or Broken with equal probability. Repair earns −4 and makes it Good. In Good, Run earns 10; in Broken, Repair earns −20. With one step left, Worn favors Run: 6>−4. With two steps left and γ=0.9, Repair gives −4+0.9(10)=5. Run gives 6+0.9[0.5(6)+0.5(−20)]=−0.3. The extra time reverses the choice.

A grid world's living reward, earned on nonterminal steps, changes the cost of delay. Negative step rewards encourage reaching an exit; a larger penalty can make a nearby bad exit preferable to a long route. A sufficiently large positive step reward can favor staying in the grid. The exact choice also depends on discounting, distances, and slip risks.

Key Takeaways

  • A return discounts later rewards; the current reward has weight 1.
  • Policies are compared by expected return across possible runs.
  • Bounded rewards and a discount below 1 bound infinite returns.
  • A finite horizon can make the best action depend on time remaining.
  • Living rewards change the value of delay and termination.

1.3 Build a state and reward model

Formulating an MDP turns a practical objective into decisions a computer can evaluate. Start by choosing when decisions happen. Then define an observable state, legal actions, transition probabilities, rewards, any terminal states, and a discount or horizon. The quality of the resulting policy depends on these choices.

Model machine maintenance

Suppose a machine is inspected once per decision step. Its condition is Good, Worn, or Broken. The model is:

StateActionRewardNext condition
GoodRun+10Good with 0.8; Worn with 0.2
WornRun+6Worn with 0.5; Broken with 0.5
WornRepair−4Good with 1
BrokenRepair−20Good with 1

Broken is not terminal: repair lets work continue. The task is continuing, with γ=0.9. Notice that available actions depend on the state; Run is unavailable when Broken.

Solving this model gives optimal values about 78.64 in Good, 66.78 in Worn, and 50.78 in Broken. In Worn, Repair has value −4+0.9(78.64)≈66.78. Run has value 6+0.9[0.5(66.78)+0.5(50.78)]≈58.90. The negative immediate reward for repair buys access to a more productive future.

Choose enough state information

The state must support predictions of both outcomes and rewards. A moving ball's position alone omits its velocity, so two identical positions can have different next positions. A board-game position also needs whose turn it is. If remaining time changes which actions pay off, include it in a finite-horizon decision rule or augment the state with it.

Extra variables increase the state space. Ten yes/no variables allow 210=1024 combinations. Keep information that changes predictions or rewards; storing the entire history can make a workable model needlessly large. The usual stationary MDP assumes the same transition and reward rules over time. Hidden state calls for a belief model, while strategic opponents call for a game model.

Make the reward express the objective

A cleaning robot rewarded for each piece of dirt collected can profit by spilling and recollecting dirt. This is reward hacking: successful optimization of a poor measure. A reward tied to the desired cleanliness avoids that particular loop. A sparse goal reward states success clearly but supplies little feedback during a long attempt.

Reward shaping adds feedback about progress. Arbitrary bonuses can change the objective. Two useful comparisons are:

  • Multiplying all rewards by the same positive number preserves their policy ranking.
  • Adding a constant to every reward preserves optimal policies in a continuing discounted task, because every policy gains the same discounted constant. In an episodic task, longer and shorter runs gain different amounts, so the ranking can change.

A policy-preserving shaping term has the form F(s,a,s′)=γΦ(s′)−Φ(s). Here Φ assigns a potential to each state. With bounded potentials in a continuing discounted task, the added discounted terms cancel except for a start-state offset. For episodic tasks, setting every terminal potential to 0 removes the leftover terminal term. A nonzero terminal potential can change which ending, or which stopping time, is preferred.

Key Takeaways

  • Define the decision timing before choosing states, actions, and rewards.
  • States need enough information for predictions without unnecessary history.
  • A broken machine can be a continuing state if repair remains possible.
  • Reward design determines what the agent actually optimizes.
  • Positive reward scaling preserves optimal policies; constant shifts need the right task setting.
  • Potential-based shaping preserves optimal policies under its boundary conditions.
2

Express values with Bellman equations

An immediate reward tells only part of the story. A state can be valuable because it opens up good decisions later, and an action can be costly now but worthwhile over time. State values and action values put numbers on those possibilities. Bellman equations connect each value to the states that can follow, using a probability-weighted average for chance outcomes and a choice among the actions the agent controls.

2.1 Read state values and action values

A value measures the return available from a situation under a particular way of acting. It includes future rewards, weighted by their probabilities and timing. This makes values different from the reward earned on a single transition.

Distinguish the starting choice

The state value Vπ(s) is the expected discounted return starting in state s and following policy π. The action value Qπ(s,a) fixes the first action to a, then follows π afterward. It does not mean taking a at every later step.

Optimal values replace that continuation policy with the best possible behavior. Thus V∗(s) is the best expected return from s, and Q∗(s,a) is the best expected return after the first action is fixed. Their relationship is

V∗(s)=max⁡aQ∗(s,a),π∗(s)∈arg⁡max⁡aQ∗(s,a).

The maximum is a number; the argmax identifies an action attaining it. If several actions tie, any tied action can be selected.

Read the robot's choices

For the delivery robot with γ=0.9, the optimal Q-values are:

StateWorkCharge
High31.5028.35
Low13.7128.35

Each row's maximum is the state's optimal value. High favors Work; Low favors Charge. Charge earns 0 immediately, but in Low it restores access to High and its better future opportunities. Work in Low still has positive optimal Q-value because a surviving robot can charge afterward.

The continuation policy matters. Under "always Work," the state values fall to about 8.27 in High and −3.48 in Low. The model has not changed; the decisions after each outcome have changed. A number labeled only "the value" is incomplete unless the intended policy or optimality is clear.

See choices and chance as separate layers

An expectimax tree alternates two kinds of nodes. At a state the agent selects an action; at a state–action pair, sometimes called a q-state, chance selects the next state according to the transition model. The agent maximizes across actions and averages across their outcomes.

A cyclic MDP repeats the same states at many tree locations. Dynamic programming stores a value for each state and reuses it. This avoids recomputing the same continuation problem every time a tree path returns to that state.

Extract a policy from the available values

With a Q-table, compare the action values in the current row. No transition model is needed. With state values alone, first calculate an action's expected reward plus discounted successor value:

∑s′T(s,a,s′)[R(s,a,s′)+γV(s′)].

That calculation needs transitions and rewards. Merely choosing the action that can reach the highest-value successor ignores how likely that successor is and what the action costs. A high expected value also leaves room for an unlucky run: it describes an average over outcomes, not a guaranteed reward on every attempt.

Key Takeaways

  • A state value assumes a continuation policy from the start.
  • A Q-value fixes the first action and then uses the stated continuation policy.
  • The maximum Q-value gives the state value; an argmax gives an action.
  • A Q-table supports action selection without a transition model.

2.2 Connect values with Bellman equations

A run's return can be split after its first transition: the immediate reward plus the discounted return from the next state. Taking an expectation produces a Bellman equation. It connects a state's value to successor values, including the possibility of returning to the same state.

Evaluate a fixed policy

For a deterministic policy, only its selected action appears:

Vπ(s)=∑s′T(s,π(s),s′)[R(s,π(s),s′)+γVπ(s′)].

Each branch contributes its probability times its immediate reward plus future value. There is one equation per state. In a finite discounted MDP, these are linear equations with a unique solution.

For the robot's "always Work" policy, begin at Low. The two possible transitions give

V(L)=0.6[4+0.9V(L)]+0.4[−10+0.9(0)].

Expand and collect the unknown: V(L)=2.4+0.54V(L)−4, so 0.46V(L)=−1.6. Therefore V(L)≈−3.48. The −10 reward remains even though Dead's future value is 0.

At High, both outcomes earn 4, so their immediate rewards combine to 4:

V(H)=4+0.9[0.7V(H)+0.3V(L)].

Collecting terms gives 0.37V(H)=4+0.27V(L). Using the unrounded Low value yields V(H)≈8.27. Keep full precision while substituting; round the reported values at the end.

Add the choice of action

For optimal values, calculate the expectation for each available action, then take the best:

V∗(s)=max⁡a∑s′T(s,a,s′)[R(s,a,s′)+γV∗(s′)].

The maximization sits outside the sum because the agent chooses one action before seeing the outcome. Choosing a different current action for each possible next state would give it information it does not yet have.

The Q-form fixes that first action but allows the best next action after observing the successor:

Q∗(s,a)=∑s′T(s,a,s′)[R(s,a,s′)+γmax⁡a′Q∗(s′,a′)].

These optimality equations contain maxima, so a single fixed-policy linear solve does not directly solve them.

Check proposed values

Use the robot's candidate optimal values V(H)≈31.50 and V(L)≈28.35. At High, Work gives 4+0.9[0.7(31.50)+0.3(28.35)]≈31.50. Charge gives 0.9(31.50)=28.35. The larger result matches the candidate High value.

At Low, Work gives 0.6[4+0.9(28.35)]+0.4(−10)≈13.71; Charge gives 28.35. The maximum matches the candidate Low value too. A check of only one state would leave the other equation untested. Small discrepancies are expected when the candidate values have been rounded.

Discount only the future term. Replacing R+γV with γ(R+V) incorrectly delays the immediate reward by one step.

Key Takeaways

  • Bellman equations split return into an immediate reward and discounted continuation.
  • A fixed policy gives a linear system with one equation per state.
  • Optimality maximizes over complete action expectations.
  • A terminal successor removes the future term, while retaining the transition reward.
  • Check every state equation when testing candidate values.
3

Solve known MDPs with dynamic programming

When transitions and rewards are known, an agent can calculate how to act before collecting new experience. Policy evaluation measures one proposed behavior. Value iteration searches for optimal values, and policy iteration improves a complete policy in rounds. These methods reuse values across repeated states, making small cyclic problems manageable without expanding an ever-growing tree of possible futures.

3.1 Calculate how good a policy is

Policy evaluation asks how much expected return a fixed policy earns. The model and policy are known. No action choices are improved during this calculation; the output is Vπ, which can later support a separate improvement step.

Solve the equations exactly

Take the policy "Work when High, Charge when Low" and γ=0.9. Charging Low gives no immediate reward and always reaches High, so V(L)=0.9V(H). Working High gives

V(H)=4+0.9[0.7V(H)+0.3V(L)].

Substitute the first equation into the second:

V(H)=4+0.63V(H)+0.243V(H)=4+0.873V(H).

Then 0.127V(H)=4, giving V(H)=4/0.127≈31.50 and V(L)≈28.35. This establishes the values of that policy. Proving it optimal also requires checking competing actions.

Exact evaluation solves one linear equation per nonterminal state. Standard dense elimination costs on the order of ∣S∣3 operations. The method is convenient for a small model because the relationships can be inspected directly.

Evaluate by repeated sweeps

An iterative alternative starts with V0(s)=0 and applies the fixed-policy backup to every state:

Vk+1(s)=∑s′T(s,π(s),s′)[R(s,π(s),s′)+γVk(s′)].

Each new value uses the old array. For "always Work," the first three sweeps, in the order High then Low, give:

SweepHighLow
000
14−1.6
26.088−2.464
3about 7.170about −2.931

For example, the second Low value is 0.6[4+0.9(−1.6)]+0.4(−10)=−2.464. High in that same sweep uses the old High value 4 and old Low value −1.6, giving 4+0.9[0.7(4)+0.3(−1.6)]=6.088.

With a discount below 1, the sweeps converge to about 8.27 and −3.48. A dense fixed-policy sweep costs on the order of ∣S∣2 operations because each state sums over successors. Sparse transition models can skip successors with probability 0.

Interpret intermediate values

Starting at zero, Vk(s) is the expected discounted reward over the next k transitions under the fixed policy, with no value beyond that horizon. The first sweep sees only immediate rewards. The second includes one more transition. These intermediate values have a clear meaning even before convergence.

Updating in place uses some freshly computed values within the same sweep. With the usual discounted conditions it can also converge, but its intermediate arrays need not equal these synchronous finite-horizon values. In a hand calculation, keep separate old and new arrays when comparing synchronous sweeps.

Do not add a maximum over actions during evaluation. That would let the agent change its behavior and would answer a different question from the one the fixed policy defines.

Key Takeaways

  • Evaluation computes a fixed policy’s values without changing its actions.
  • Exact evaluation solves the policy’s Bellman equations.
  • Synchronous iterative evaluation uses the previous array throughout a sweep.
  • Zero-initialized sweep k evaluates k transitions under that policy.

3.2 Find optimal values by repeated backups

Value iteration repeatedly asks what is best when one more decision is allowed. It starts from V0=0 and backs up each state's best expected reward plus discounted successor value. The same calculation handles cycles because successor values come from a stored array.

Make one complete sweep

For every nonterminal state, calculate

Vk+1(s)=max⁡a∑s′T(s,a,s′)[R(s,a,s′)+γVk(s′)].

For the robot's first sweep, all future terms are 0. High compares Work at 4 with Charge at 0, so V1(H)=4. Low compares Work at 0.6(4)+0.4(−10)=−1.6 with Charge at 0, so V1(L)=0.

The second sweep uses this entire old array. At High, Work gives 4+0.9[0.7(4)+0.3(0)]=6.52, while Charge gives 0.9(4)=3.6. At Low, Work still gives −1.6, while Charge gives 3.6. Thus V2=(6.52,3.6). A third sweep gives about (9.08,5.87).

If the new High value 6.52 were used immediately to update Low, the result would differ. That is an in-place update, not the synchronous second sweep just shown.

Understand what converges

From zero initialization, Vk is the optimal expected return with exactly k decision opportunities remaining, allowing terminal episodes to end sooner. Each sweep extends the useful planning horizon by one. The Bellman optimality operator is a contraction for γ<1: the largest error over states shrinks by at least a factor of γ per application. Values converge to the unique V∗ from any finite starting array.

A dense sweep considers states, actions, and successors, costing on the order of ∣S∣2∣A∣ operations. A discount close to 1 usually slows convergence because distant rewards retain more weight.

Stop with an error bound

Let Δk=max⁡s∣Vk+1(s)−Vk(s)∣. For 0<γ<1, the new array's maximum error is bounded by γΔk/(1−γ). To ensure error below a chosen tolerance ε, it is sufficient that

Δk<ε(1−γ)/γ.

For γ=0.9 and tolerance 0.01, the threshold is about 0.00111. A change below 0.01 alone does not certify value error below 0.01. At γ=0, a single backup gives the optimal immediate rewards, so no division by the discount is needed.

Read out the policy

After stopping, compare action expectations using the final value array. This one-step lookahead gives a greedy policy. The policy can settle before the values: the robot's greedy policy from V1 already says "Work when High, Charge when Low," but its values need 77 sweeps to come within 0.01 of the optimal pair (31.50,28.35).

A stable-looking policy and accurate values are different checks. The backup must compare expected outcomes for each action; selecting the single most valuable possible successor leaves out both risk and immediate reward.

Key Takeaways

  • Value iteration applies a maximum over action expectations at every state.
  • Zero-initialized sweep k gives optimal k-step values.
  • Discounting makes the optimality backup a contraction.
  • The largest sweep change needs scaling before it certifies value error.
  • Extract a policy with a complete one-step lookahead.
  • An optimal greedy policy can appear before values are close to their limits.

3.3 Improve a policy until it stops changing

Policy iteration alternates two jobs: measure a policy, then improve its actions using that measurement. Start from any deterministic policy. A good initial guess can save work, but it is not required for correctness in a finite discounted MDP.

Separate evaluation from improvement

First compute Vπi, the values of the current policy. Then, for every state, compare all actions using those same values:

πi+1(s)∈arg⁡max⁡a∑s′T(s,a,s′)[R(s,a,s′)+γVπi(s′)].

Evaluation describes the old behavior. Improvement asks whether changing the first action would improve the return if the old policy were followed afterward. Changing all such actions gives a policy at least as good in every state. If the old policy is not optimal, an improvement is strict in at least one state.

Keep the current action whenever it ties for best. Otherwise, equally good actions can make a policy appear to keep changing even though there is no value improvement.

Improve the robot's policy

Start with "always Work." Exact evaluation gives High about 8.27 and Low about −3.48. In High, keeping Work gives 8.27; switching to Charge gives 0.9(8.27)≈7.45. Keep Work. In Low, Work gives −3.48 and Charge gives about 7.45. Switch Low to Charge.

Now evaluate the new policy "Work when High, Charge when Low." Its values are about 31.50 and 28.35. Improve again:

StateWork expectationCharge expectationKeep
High31.5028.35Work
Low13.7128.35Charge

No action changes, so policy iteration stops. The fixed-policy values also satisfy the optimality equations, establishing that this policy is optimal. The robot needed two full evaluations from this starting policy.

Explain why the process ends

A finite MDP has only finitely many deterministic policies. If every one of ∣S∣ states has ∣A∣ choices, there are ∣A∣∣S∣ such policies. The robot has two nonterminal states with two actions each, giving 22=4 policies. With strict improvement whenever needed and consistent tie handling, the process cannot return to a worse policy and must finish.

Compare the planning methods
MethodMain repeated workStopping idea
Value iterationOne optimality backup per stateBound remaining value error
Policy iterationPolicy evaluation, then action improvementPolicy unchanged after improvement
Modified policy iterationA few evaluation sweeps, then improvementContinue partial evaluation and improvement to convergence

Full evaluations make policy-iteration rounds more expensive, but often fewer rounds are needed. The robot's 77 value-iteration sweeps and two policy evaluations are different units of work, so the counts alone do not establish which method is faster. Use values belonging to the current policy during each improvement; mixing them with values from a previous policy breaks that step's meaning.

Key Takeaways

  • Policy iteration alternates evaluation and improvement.
  • Improvement compares actions using one consistent policy-value array.
  • Keep the current action on ties and stop when no action changes.
  • Finite policies and monotone improvement ensure termination.
  • Fewer policy-iteration rounds can still involve more work per round.
4

Learn about an unknown MDP from experience

A learning agent often starts without reliable transition probabilities or reward predictions. It must learn from observed actions and outcomes. One route estimates a model and then plans; another estimates values directly. Comparing whole-episode returns with one-step temporal-difference updates shows how feedback can teach an agent even before an episode ends, and why limited experience can give misleading estimates.

4.1 Learn a model from observed transitions

In reinforcement learning, an agent learns from experience in a decision problem. It observes a state, chooses an available action, and receives a sample (s,a,r,s′): the previous state, action, reward, and next state. The objective remains high expected return, but transition probabilities and rewards must be learned.

Separate learning from planning

Planning uses an MDP model to calculate values or policies. It can happen before acting or while an agent replans during operation. Learning uses observed experience, either from ongoing interaction or from a previously collected data set. Offline reinforcement learning still learns from experience; it simply uses recorded experience.

In passive learning, a policy is fixed and the task is to estimate how well it performs. In active learning, the agent also chooses actions to discover better behavior. Those choices affect both collected reward and the information available for future updates.

Estimate transitions with counts

A model-based learner records how often each action is tried in each state. Let N(s,a) count those trials and N(s,a,s′) count the trials ending in a particular successor. Then

T^(s,a,s′)=N(s,a,s′)N(s,a).

The counts in the numerator partition the trials in the denominator, so their estimated probabilities sum to 1. An untried pair has denominator 0 and needs more experience or an explicit modeling choice; it has no empirical transition distribution yet.

For the robot, Work in High was tried 20 times: 13 transitions stayed High and 7 reached Low. The estimates are 13/20=0.65 and 7/20=0.35. Work in Low was tried 10 times: 7 survived and 3 reached Dead, giving 0.7 and 0.3. The second estimate understates the true death probability 0.4.

Record rewards for each transition too. The robot has fixed rewards for its outcomes. If repeated identical transitions have noisy rewards, estimate their conditional mean reward from the observed samples.

Plan with the learned model

Use the estimated transitions and rewards in value iteration or policy iteration. For these robot counts, with Charge transitions known and γ=0.9, the estimated optimal values are about (30.42,27.38). The optimal action choices still match the true model: Work in High, Charge in Low. Similar policies can therefore arise from different value estimates.

Few samples can give inaccurate models. More representative experience improves the estimates, but collecting data only under one narrow policy can leave useful actions untried. A model-based learner still needs exploration.

Compare two learning routes
RouteWhat is learnedHow it supports decisions
Model-basedTransition and reward estimatesPlan in the estimated MDP
Model-freeValues or action valuesUse learned values directly, with the needed action information

A learned model can reuse samples for many planning backups and support replanning when objectives change. It also takes storage and computation, and model errors can distort the plan. Model-free methods avoid building a transition table, but usually require substantial experience to make their value estimates reliable.

Key Takeaways

  • Reinforcement learning uses experience; planning uses a model.
  • Passive learning evaluates a fixed policy; active learning also chooses actions.
  • Estimate each transition probability from its state–action trial count.
  • An untried action has no empirical transition estimate.
  • A model-based learner plans with its estimated model.
  • Model-free learning estimates values without first learning transitions.

4.2 Learn values from returns and TD targets

A fixed policy can be evaluated without knowing its transition model. Direct evaluation averages complete sampled returns. Temporal-difference learning, or TD learning, updates from a single reward and an estimated successor value. Both learn the policy's values from experience.

Average whole-episode returns

Follow "always Work" with γ=0.9. One robot episode is High → High (+4), High → Low (+4), Low → Dead (−10). The returns from its High visits are 4+0.9(4)+0.81(−10)=−0.5 and 4+0.9(−10)=−5. Its Low return is −10.

A second episode is High → Low (+4), Low → Low (+4), Low → Dead (−10). Its High return is −0.5; its Low returns are −5 and −10. The every-visit means are therefore (−0.5−5−0.5)/3=−2 for High and (−10−5−10)/3≈−8.33 for Low. A first-visit method would count only the first visit to a state in each episode.

These estimates differ sharply from the true policy values (8.27,−3.48) because both episodes ended quickly. Whole returns have sampling variation. With sufficient representative completed episodes, their averages approach the policy's expected returns. Direct evaluation waits until the required return is available at episode end and estimates states separately.

Update after one transition

TD uses the current estimate of what follows:

V(s)←V(s)+α[r+γV(s′)−V(s)].

The target is r+γV(s′). The TD error is target minus current estimate. The learning rate α controls the fraction of that error used in the update.

Suppose V(H)=10, V(L)=8, γ=0.9, and α=0.5. After High → Low with reward 4, the target is 4+0.9(8)=11.2. The error is 11.2−10=1.2, so the new High estimate is 10+0.5(1.2)=10.6. Low's stored value remains 8 on this update. A terminal next state contributes no future term.

TD bootstraps: it uses an estimate to improve another estimate. This passes information through connected states and permits updates in continuing tasks, but early targets can be biased by poor successor estimates.

Control how much new evidence counts
MethodUpdate targetNeeds a completed episode?
Direct evaluationSampled discounted returnYes, for the complete return
One-step TDReward plus discounted estimated next valueNo

A large learning rate reacts strongly to each target. At α=1 the old estimate is replaced by the latest target. A fixed positive rate generally keeps tracking sample noise. Suitably decreasing rates, with repeated visits and the usual finite discounted assumptions, support tabular TD convergence. A rate 1/N(s) averages the sequence of observed TD targets; those targets themselves change as successor estimates improve.

State values alone do not reveal the best action without transition and reward information for a lookahead. Passive TD evaluates the behavior generating its samples. Learning action values gives an agent a direct way to compare actions without first learning a model.

Key Takeaways

  • Direct evaluation averages complete returns from sampled visits.
  • TD updates toward an immediate reward plus discounted next-state estimate.
  • The TD error is target minus the current estimate.
  • Bootstrapping permits learning before an episode ends.
  • A decreasing learning rate must be paired with repeated visits for convergence.
  • State values alone require a model to compare actions by lookahead.
5

Learn to act with Q-learning and exploration

Choosing actions creates a second challenge for a learning agent: its decisions determine the experience it receives. Q-learning estimates action values directly, while exploration makes useful evidence available. A compact feature representation can share learning across many states, but it also changes the reliability guarantees. The central questions are what the update targets, how actions are sampled, and what the representation can express.

5.1 Update action values with Q-learning

Q-learning learns action values from observed transitions. Its target assumes the best next action, even while the agent chooses exploratory actions. This lets it learn how to act well without estimating a transition model.

Replace an expected backup with a sample

A model-based Q-backup averages over all possible successors:

Qk+1(s,a)=∑s′T(s,a,s′)[R(s,a,s′)+γmax⁡a′Qk(s′,a′)].

Q-learning sees one successor at a time. After a sample (s,a,r,s′), it computes

y=r+γmax⁡a′Q(s′,a′)

and updates Q(s,a)←Q(s,a)+α[y−Q(s,a)]. A terminal successor makes y=r. The maximum is over actions available in the next state, not the state just left.

Initialize the Q-table, choose an action with an exploration rule, observe the result, update the selected entry, and continue from the next state. Restart after termination. To use the learned policy, select an action attaining the largest Q-value in the current row.

Work through two updates

Let γ=0.9 and α=0.5. Initially Q(L,Work)=5. The robot tries Work in Low and dies with reward −10. The target is −10, so the new value is 5+0.5(−10−5)=−2.5. There is no future return after Dead.

Next suppose Q(H,Work)=6 and the robot works High, earns 4, and reaches Low. At Low the estimates are Work at −2.5 and Charge at 3. The best next value is 3, making the target 4+0.9(3)=6.7. The updated High–Work value is 6+0.5(6.7−6)=6.35. This sample updates only that table entry.

Distinguish target behavior from actual behavior

Q-learning is off-policy: the continuation in its target is greedy, even if its action-selection rule explores. SARSA is on-policy: it uses r+γQ(s′,a′) for the action actually chosen next.

MethodNext action used in targetValues being learned
Q-learningHighest current next Q-valueOptimal action values, under convergence conditions
SARSAActual next actionAction values of the behavior policy

Near a cliff, an exploring agent can take accidental dangerous steps. SARSA accounts for those future exploratory actions and can learn a more cautious route. Q-learning targets the greedy continuation and can favor a shorter edge route, even while exploration makes its training trips risky.

State the tabular guarantee precisely

In a finite stationary MDP with bounded rewards and γ<1, tabular Q-learning converges to Q∗ with probability 1 when every state–action pair receives infinitely many updates and its learning rates satisfy

∑nαn=∞,∑nαn2<∞.

A per-pair rate 1/N(s,a) has this form. A rate 1/N(s,a)2 decreases too quickly: its total sum is finite, so it can leave too little adjustment to remove an initial error. Infinite total adjustment prevents learning from stopping too early; finite squared adjustment controls accumulated noise. Constant rates generally retain fluctuations in stochastic tasks. These are limiting conditions, so a finite training run still needs evaluation.

Key Takeaways

  • Q-learning moves one action value toward a sampled optimality target.
  • The target maximizes over next-state actions.
  • A terminal successor makes the target equal to the observed reward.
  • Off-policy learning separates the target policy from exploratory behavior.
  • Tabular convergence requires repeated coverage and suitable per-pair learning rates.

5.2 Choose useful actions while learning

Exploitation selects the action that currently looks best. Exploration gathers information that may reveal a better choice. If an early unlucky Work attempt makes the robot prefer Charge in High, pure exploitation can keep it charging forever and leave the Work estimate uncorrected.

Count the random branch correctly

An epsilon-greedy rule explores uniformly with probability ε and otherwise chooses a greedy action. Suppose there is one greedy action among four and ε=0.2. Its selection probability is 0.8+0.2/4=0.85. Each other action has probability 0.05. The random branch includes the greedy action too.

Lower exploration early in training can leave useful actions untested; high exploration late in training keeps sacrificing reward. A schedule can become greedy in the limit while still trying every relevant pair infinitely often. This GLIE property is stronger than simply reducing epsilon, and reachability matters for whether all states are visited.

Favor actions with little evidence

An exploration function can add a bonus to a value estimate. With f(u,n)=u+k/n for a tried action, choose the action with the largest score. Give untried actions priority, such as score +∞. With k=10, a value 5 tried 20 times scores 5.5; a value 4 tried twice scores 9. The less-tried action is selected despite its lower current estimate.

The bonus can also enter a backup target: r+γmax⁡a′f(Q(s′,a′),N(s′,a′)). This propagates the attraction of unexplored actions to earlier states. Optimistic initial Q-values can also encourage trying actions whose estimates have not yet been corrected by experience.

Use a confidence bound for bandits

A multi-armed bandit has one decision state and several arms with unknown fixed mean rewards. Each pull teaches the agent about an arm's reward distribution. UCB1 assumes bounded independent reward draws with a fixed distribution per arm; rescale rewards to the range 0 to 1. Pull every arm once, then choose the largest score

xˉj+2ln⁡Nnj.

Here xˉj is arm j's sample mean, nj its pull count, and N the total count across arms. The bonus grows for poorly sampled arms. With means 0.6 and 0.5 after 10 and 2 pulls, N=12. The scores are about 1.30 and 2.08, so the second arm is selected. The score can exceed 1 even though observed rewards cannot: it is a decision index, not an observed reward.

Measure the cost of learning

Regret compares collected reward with what optimal choices would have earned. In a stationary bandit with a genuinely inferior arm, fixed positive epsilon keeps selecting that arm at a positive rate, producing linear expected regret. Under its stochastic bandit assumptions, UCB1 has logarithmic expected regret. A carefully tuned decreasing-epsilon schedule can also achieve that order; arbitrary decay cannot promise it.

Q-learning's off-policy target permits exploratory samples without redefining the optimal values it seeks. Exploration still affects the reward collected during training. For physical systems, use simulation, recorded experience, or permitted-action limits to keep exploration from causing harm.

Key Takeaways

  • Epsilon-greedy exploration can randomly select the greedy action too.
  • Exploration bonuses favor actions with limited evidence.
  • UCB1 balances sample means against count-based uncertainty.
  • Regret measures the reward cost of learning over time.
  • Decreasing epsilon alone does not establish adequate exploration or logarithmic regret.
  • Exploratory behavior can be costly even when an off-policy target is correct.

5.3 Share learning through features

A Q-table stores one number for every state–action pair. In a large problem, many pairs may never be visited. Separate entries also fail to share evidence between similar situations. Approximate Q-learning replaces the table with a function of features.

Represent values with a weighted sum

A feature fi(s,a) is a number describing an aspect of the state and action. For a delivery robot, features could describe battery level, distance to a charger, and waiting packages. A linear approximation writes

Q(s,a)=∑iwifi(s,a).

The weights wi describe how strongly each feature contributes. Features can depend on the action as well as the state, allowing different choices in the same state to have different values.

Update every weight from one error

Compute the current Q-value, then the target y=r+γmax⁡a′Q(s′,a′). The difference δ=y−Q(s,a) drives each update:

wi←wi+αδfi(s,a).

All values used for the target and error come from the weights before the update. A zero feature produces no change to its weight. A nonzero feature scales the adjustment, including its sign.

For weights (1,−0.5) and current features (1,2), the estimate is 1(1)+(−0.5)(2)=0. Suppose the reward is 4, the best next Q-value is 4, and γ=0.9. The target is 4+0.9(4)=7.6, so δ=7.6. With α=0.1:

w1=1+0.1(7.6)(1)=1.76, w2=−0.5+0.1(7.6)(2)=1.02.

The new estimate for the same features becomes 1.76+1.02(2)=3.8. A shared-weight update is not the same as replacing one independent table entry by the target.

Understand the reach and limits of sharing

One weight participates in many predictions. Updating it changes values for every pair with a nonzero value of that feature. This is generalization, and it can help the agent act sensibly in unseen states. It can also spread a mistaken update.

If two situations have identical feature vectors for every corresponding action, the model must give them identical action values. If they require different actions, no amount of weight tuning can represent both decisions correctly. Better features or a richer function are needed. Tabular learning is the special case with one indicator feature for each state–action pair, active only for that pair.

RepresentationSharingReliability issue
Q-tableEach pair has its own entryNeeds enough visits to each pair
Linear featuresShared weights affect many pairsFeatures can miss important distinctions
Neural networkLearns a richer nonlinear representationTraining and stability need additional methods

The convergence guarantee for tabular Q-learning does not extend to arbitrary function approximation. Off-policy bootstrapping with shared predictions can oscillate or diverge, so evaluate the learned policy on separate trials. Deep Q-networks learn features from inputs such as game-screen pixels; policy search instead adjusts a policy directly to increase return.

Key Takeaways

  • Linear Q-approximation predicts values from weighted state–action features.
  • Each weight update uses the same pre-update prediction error.
  • Shared features let one sample change predictions for many pairs.
  • Identical feature vectors cannot represent different values.
  • Tabular convergence guarantees do not generally extend to function approximation.

Reinforcement Learning examples

5 Walkthroughs

1

Build and judge a decision model

13 steps
Model the delivery robot, calculate a return, and check how state and reward choices affect behavior.
  1. 1
    IntroductionDecisions with uncertain outcomes

    A robot chooses whether to work or charge. It controls that decision, but it cannot choose whether a low battery survives another job. Repeated choices under chance like this form a Markov decision process (MDP).

    We will describe those choices with states and probabilities, compare rewards across time as a discounted return, and examine how a model can accidentally reward the wrong behavior (reward hacking).

  2. 2
    ExplanationDescribe one transition

    One MDP transition has four observable parts: current state, chosen action, reward, and next state. A model adds the probabilities of possible outcomes.

    For Work in High, the robot earns 4 and reaches High with probability 0.7 or Low with probability 0.3. These probabilities sum to 1. A Work choice does not let the robot select which branch occurs.

  3. 3
    ExampleDistinguish failure from continuation

    Work in Low has two outcomes: remain Low with probability 0.6 and reward 4, or enter Dead with probability 0.4 and reward −10.

    Dead is terminal, so its future value is 0. The −10 is still received on entry. Charge in Low earns 0 and reaches High for certain. Charge in High earns 0 and stays High.

  4. 4
    ChallengeCheck what the state remembers

    A moving object's next position depends on its position and velocity. A proposed state records position alone. Why can two visits to the same recorded state have different predictions?

    ---reveal---

    The two visits can have different velocities. Adding velocity lets the state distinguish those situations. The Markov property requires the state to retain relevant information from the past; it does not require the physical world to forget its past.

  5. 5
    ConnectionReplace a route with a policy

    A fixed route assumes the agent reaches the expected states. Random outcomes can push it elsewhere, so a policy supplies a response for each state.

    "Work when High, Charge when Low" is a deterministic stationary policy: the same state always produces the same action. A finite deadline can require a rule that also considers time remaining.

  6. 6
    ExampleWeight each reward by its delay

    Suppose a run earns −1, −1, −1, then 10 and ends. At discount 0.9, the weights are 1, 0.9, 0.81, and 0.729.

    The return is −1−0.9−0.81+0.729(10)=4.58. The first reward is not discounted. A lower discount places less weight on the late payoff; at 0.5, this same run has return −0.5.

  7. 7
    ChallengeCompare patience with a deadline

    A worn machine can Run for reward 6 or Repair for reward −4. With one decision left before the task ends, which action has higher return? Why might the answer differ earlier in the task?

    ---reveal---

    Run is best on the last step because 6>−4 and no later rewards remain. Earlier, repair can restore access to higher production rewards. A finite-horizon policy can therefore choose differently in the same condition at different times.

  8. 8
    Key InsightBound a continuing return

    An infinite run can have a finite discounted return. If every reward has magnitude at most 10 and the discount is 0.9, the geometric sum gives ∣U∣≤10/(1−0.9)=100.

    For the robot, no positive reward exceeds 4, so return also cannot exceed 40. These bounds use the entire reward stream; the approximate 10-step effective horizon is not a cutoff.

  9. 9
    ExplanationChoose states that support predictions

    Before listing states, decide when actions occur and what affects their consequences. A maintenance model can use Good, Worn, and Broken, with different legal actions in each.

    Broken is not terminal if Repair can return the machine to Good. More state detail has a cost: ten yes/no variables already allow 1,024 combinations. Keep variables that change outcomes or rewards.

  10. 10
    ChallengeCheck the objective behind a reward

    A cleaning robot earns one reward for every piece of dirt it collects. It can spill stored dirt and collect it again. What defect does this reveal in the reward design?

    ---reveal---

    The measure rewards repeated collection even when cleanliness does not improve. This is reward hacking: optimizing the specified number through an unintended behavior. A reward tied to the desired cleanliness addresses this particular incentive.

  11. 11
    ExplanationShape progress without changing the goal

    Potential-based shaping adds γΦ(s′)−Φ(s) to a transition reward. Discounted terms cancel across a run, leaving an offset determined by the start when the boundary conditions hold.

    Use bounded potentials in a continuing discounted task and zero terminal potentials in an episodic task. An arbitrary progress bonus can change the preferred behavior instead of merely helping the learner find it.

  12. 12
    ChallengeConnect stopping time with rewards

    Two navigation policies reach the same exit, one quickly and one after a detour. The designer adds a positive reward to every transition. Must their original ranking stay the same?

    ---reveal---

    No. The detour receives extra step rewards, so the added discounted totals can differ and change the ranking. A constant shift is policy-preserving for a continuing discounted stream, but variable episodic lengths break that equal-offset argument.

  13. 13
    RecapInspect a model before solving it

    Check three things before computing values: does the state support predictions, do each action’s probabilities sum to 1, and does the reward express the intended objective?

    Then identify terminal states and the discount or horizon. Those choices determine which future rewards the policy should pursue.

2

Turn future rewards into Bellman equations

10 steps
Separate state values from action values, solve the robot’s fixed-policy equations, and check an optimality backup.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSummarize a branching future
  2. 2
    ExplanationName the continuation behavior
  3. 3
    ExampleRead the maximum and the action
  4. 4
    ChallengeInterpret a first action correctly
  5. 5
    ExplanationSplit the return after one transition
  6. 6
    ExampleSolve the Low equation first
  7. 7
    ExampleSubstitute into High
  8. 8
    ChallengeKeep choice before chance
  9. 9
    ChallengeCheck optimality using the right continuation
  10. 10
    RecapIdentify the equation you need
3

Solve the robot with two planning methods

15 steps
Evaluate a policy, compute synchronous value-iteration sweeps, and improve a policy until its actions are stable.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionUse a known model to plan
  2. 2
    ExplanationFix the policy before evaluating
  3. 3
    ExampleSolve the linked equations
  4. 4
    ChallengeInterpret an evaluation sweep
  5. 5
    ExampleStart value iteration from zero
  6. 6
    ExampleCompute the second High backup
  7. 7
    ChallengeFinish the synchronous sweep
  8. 8
    TipTurn small changes into an error test
  9. 9
    Key InsightNotice when actions settle early
  10. 10
    ExampleStart from a poor policy
  11. 11
    ExampleEvaluate the improved behavior
  12. 12
    ChallengeHandle an equal-value alternative
  13. 13
    ConnectionCompare computation fairly
  14. 14
    ChallengeConnect stability to the optimality equation
  15. 15
    RecapChoose the planning operation
4

Learn from robot experience

12 steps
Estimate transitions, compare completed returns, and apply a TD update before the episode ends.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionReplace certainty with evidence
  2. 2
    ConnectionSeparate the learning task from planning
  3. 3
    ExampleCount successors of one action
  4. 4
    ChallengeFind the missing model row
  5. 5
    Key InsightPlan with estimates
  6. 6
    ExampleCalculate a complete return
  7. 7
    ChallengeKeep samples distinct from expectations
  8. 8
    ExplanationForm a TD target immediately
  9. 9
    ExampleApply the learning rate
  10. 10
    TipDistinguish a moving target from a return
  11. 11
    ChallengeConnect learned values to action choices
  12. 12
    RecapChoose what to estimate
5

Learn action values and share experience

18 steps
Apply Q-learning, reason about exploration probabilities, and update a linear feature model.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionLet experience improve decisions
  2. 2
    ExplanationChoose the best next-state estimate
  3. 3
    ExampleUpdate after a terminal failure
  4. 4
    ExampleUpdate after reaching Low
  5. 5
    ChallengeCompare the targets of two learners
  6. 6
    TipCheck what a convergence claim needs
  7. 7
    ExampleInclude the greedy action in random exploration
  8. 8
    ExplanationUse counts to find missing evidence
  9. 9
    ExampleDistinguish confidence from observed reward
  10. 10
    ChallengeDiagnose permanent exploration cost
  11. 11
    Key InsightDistinguish decay from adequate coverage
  12. 12
    ExplanationReplace separate entries with features
  13. 13
    ExampleCalculate the prediction and error
  14. 14
    ExampleApply the shared-weight update
  15. 15
    ChallengeFind a feature representation’s blind spot
  16. 16
    ConnectionCheck generalization as well as fit
  17. 17
    ChallengeConnect exploration, targets, and representation
  18. 18
    RecapInspect the learning loop

Reinforcement Learning practice questions

40 Practice Questions in 4 sets

Set 1: Models, improvement, and exploration10 Practice Questions

Question 1 of 10

An episodic navigation task can end after different numbers of steps. The designer adds 1 to the reward of every transition before termination. How can this affect the policy?
  1. It preserves all action rankings by scaling returns.
  2. It changes only values because every run gains equally.
  3. It can favor shorter runs by penalizing extra steps.
  4. It can favor longer runs by rewarding extra steps.
Show answerHide answer
Answer: D
Adding 1 rewards every extra transition, so runs of different lengths receive different added discounted totals. This can change whether the agent ends quickly or continues. The equal-offset argument applies to a continuing discounted stream, where every policy receives the same infinite discounted constant.

Question 2 of 10

A policy earns reward 2 on every step forever. Another earns 7 immediately and then terminates. What is the comparison at discount 0.8?
  1. The continuing policy has value 10 and is better.
  2. The terminal policy has value 7 and is better.
  3. The continuing policy has value 8 and is worse.
  4. The policies both have value 7 and are tied.
Show answerHide answer
Answer: A
The continuing return is the geometric sum 2/(1−0.8)=10. The terminal policy earns 7 with no later reward, so the continuing policy has higher return. Multiplying the continuing sum by an extra discount would give 8 and would incorrectly delay its first reward.

Question 3 of 10

A state S has two actions: Stay earns 2 and returns to S; Exit earns 7 and terminates. At discount 0.5, a proposed optimal value is V(S)=4. What value and action actually satisfy the optimality equation?
  1. V∗(S)=4; choose Stay.
  2. V∗(S)=5.5; choose Stay.
  3. V∗(S)=7; choose Exit.
  4. V∗(S)=7; choose Stay.
Show answerHide answer
Answer: C
The value 4 solves the Stay-only equation, but at that value Exit offers 7, so 4 fails optimality. Testing 7 gives Stay at 2+0.5(7)=5.5 and Exit at 7, making 7 the fixed point. The 5.5 is a one-step deviation value from 7, not the optimal state value.

Question 4 of 10

An iterative policy evaluator takes a maximum over every legal action during each backup, although a policy has already been fixed. What procedure has it implemented?
  1. Exact evaluation of the fixed policy.
  2. Value iteration for optimal state values.
  3. Direct evaluation from complete episodes.
  4. Policy evaluation with faster averaging.
Show answerHide answer
Answer: B
Maximizing over legal actions lets the backup choose behavior, so it applies the value-iteration operator. Fixed-policy evaluation instead uses the action selected by that policy. The difference is the question being answered: best possible behavior versus the return of the given behavior.

Question 5 of 10

A fixed policy uses the only action in state S. It earns 3, then returns to S with probability 0.5 or terminates with probability 0.5. What is Vπ(S) at discount 0.8?
  1. 3.00
  2. 7.50
  3. 5.00
  4. 15.00
Show answerHide answer
Answer: C
The equation is V=3+0.8(0.5V), so 0.6V=3 and V=5. The terminal branch has no continuation, but both branches earn the reward 3. The value 15 would assume a return to S after every action and would ignore the termination probability.

Question 6 of 10

An action was tried 30 times. It reached Busy 18 times and Idle 12 times. What transition probability to Idle should the empirical model record?
  1. 0.40
  2. 0.60
  3. 0.67
  4. 1.50
Show answerHide answer
Answer: A
The Idle count is divided by all trials of this state–action pair: 12/30=0.4. The remaining 18 trials give Busy probability 0.6, so the row sums to 1. Dividing 12 by 18 compares one outcome count with another; it does not normalize over all possible outcomes.

Question 7 of 10

At episode start, V(A)=V(B)=0. With discount 0.5 and learning rate 0.5, TD observes A → B with reward 0, then B → terminal with reward 8. Before any further data, how does TD’s estimate of A compare with a first-visit direct-evaluation estimate from this episode alone?
  1. TD gives 2; direct evaluation gives 4.
  2. TD gives 4; direct evaluation gives 4.
  3. TD gives 0; direct evaluation gives 8.
  4. TD gives 0; direct evaluation gives 4.
Show answerHide answer
Answer: D
The first TD target is 0 because B is still estimated at 0, so A remains 0. The terminal transition then raises B to 4 but does not revisit A. Direct evaluation can use A’s completed return 0+0.5(8)=4; assigning A the new B value would skip the timing of the TD updates.

Question 8 of 10

An agent reaches T with reward 2. At T, the next chosen action has Q-value 1, while another action has Q-value 6. With discount 0.5, what targets do Q-learning and SARSA use, respectively?
  1. Q-learning: 2.5; SARSA: 5.
  2. Q-learning: 5; SARSA: 2.5.
  3. Q-learning: 5; SARSA: 5.
  4. Q-learning: 2.5; SARSA: 2.5.
Show answerHide answer
Answer: B
Q-learning uses the largest next action value, giving 2+0.5(6)=5. SARSA uses the action actually selected, giving 2+0.5(1)=2.5. Using the selected action in both targets erases the off-policy distinction that lets Q-learning target a greedy continuation while exploring.

Question 9 of 10

A stationary bandit has a uniquely best arm and at least one inferior arm. An agent keeps a fixed positive epsilon and explores uniformly forever. How does its expected regret grow over long runs?
  1. Linearly, because inferior arms keep a positive selection rate.
  2. Logarithmically, because every arm’s estimate becomes accurate.
  3. Toward zero, because its greedy choices become more reliable.
  4. As a bounded total, because every arm is eventually understood.
Show answerHide answer
Answer: A
Even with accurate estimates, the exploration branch keeps choosing inferior arms with a fixed positive probability. Each such choice has a positive expected gap from the best arm, so cumulative expected regret grows linearly. Better estimates improve exploitation but do not remove the cost of permanent random exploration.

Question 10 of 10

A finite stationary discounted MDP has bounded rewards. A learner repeatedly updates every state–action pair using Q-learning. On the nth visit to each pair, it uses αn=1/n2. Why does the standard convergence theorem fail to guarantee learning the optimal Q-values?
  1. The squared learning rates have an infinite total despite decay.
  2. The update becomes on-policy as soon as the rates decrease.
  3. The maximum must be replaced by an average after enough visits.
  4. The total future adjustment can be finite despite repeated visits.
Show answerHide answer
Answer: D
The rates 1/n2 have a finite sum, violating the requirement that total learning-rate mass be infinite. Repeated visits alone may therefore leave too little adjustment to remove an initial error. The squared-rate sum is also finite; that condition is satisfied and is not the source of the failure.
Set 2: States, values, and first updates10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A delivery cart’s location is observed exactly, but its chance of completing a trip depends on its current battery level. The proposed state records only location. What change makes the state useful for predicting trip outcomes?
  1. Include only the number of trips completed so far.
  2. Use a lower discount factor for the same state.
  3. Include the current battery level in the state.
  4. Use the last chosen action as the entire state.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A run earns rewards 2, −3, and 8, then ends. What is its discounted return when γ=0.5?
  1. 1.25
  2. 2.50
  3. 3.00
  4. 7.00
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

At state Ready, the learned action values are Q(Ready,Send)=12 and Q(Ready,Wait)=9. What action does the greedy policy select?
  1. Send, because its action value is larger.
  2. Wait, because later rewards count for less.
  3. Send and Wait, each with equal probability.
  4. Wait, because its lower value is safer.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An action reaches A with probability 0.25 and reward 6, or B with probability 0.75 and reward −2. Their continuation values are 8 and 4. What is the action’s expected return with γ=0.5?
  1. 1.25
  2. 4.00
  3. 5.00
  4. 2.50
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A current policy chooses a at S. Its evaluation gives an action lookahead of 9 for a and 11 for b, both using the evaluated policy values. What must policy iteration do before deciding whether the revised policy is stable?
  1. Switch to b, then declare the revised policy optimal.
  2. Switch to b, then evaluate and improve the revised policy.
  3. Keep a, then stop because both actions have positive value.
  4. Average a and b, then reuse the old policy’s values.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A task has states P, Q, and terminal Done, with discount 0.5. In P, Finish earns 3 and reaches Done; Move earns 0 and reaches Q. In Q, Collect earns 8 and reaches Done. After two synchronous value-iteration sweeps from zero, what are V2(P) and the greedy action in P extracted from that array?
  1. V2(P)=3; choose Finish.
  2. V2(P)=4; choose Finish.
  3. V2(P)=8; choose Move.
  4. V2(P)=4; choose Move.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A controller estimates transition probabilities and rewards from its logs, then runs policy iteration on those estimates. What learning approach is it using?
  1. Model-based reinforcement learning.
  2. Model-free temporal-difference updates.
  3. Model-free action-value learning.
  4. Planning with a known original model.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A policy evaluator has V(S)=7 and V(T)=5. It observes S → T with reward −1. With discount 0.8 and learning rate 0.25, what is the new TD estimate for S?
  1. 3.00
  2. 6.40
  3. 6.00
  4. 7.75
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

An agent has Q(S,a)=2. After taking a it earns 1 and reaches T, where action values are 5 and 3. With discount 0.6 and learning rate 0.5, what does Q-learning assign to Q(S,a)?
  1. 3.00
  2. 2.40
  3. 4.00
  4. 4.50
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An epsilon-greedy agent has five actions and one uniquely greedy action. Its exploration probability is 0.25, with uniform random selection in the exploration branch. What is the total probability of choosing the greedy action?
  1. 0.75
  2. 0.85
  3. 0.80
  4. 0.95
Show answerHide answer

Save this lesson to see this answer.

Set 3: Check assumptions and connect the methods10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A TD target is 10 and the current state estimate is 6. With learning rate 0.2, how much does the estimate change?
  1. It increases by 2.0.
  2. It increases by 4.0.
  3. It decreases by 0.8.
  4. It increases by 0.8.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A robot moves North with intended probability 0.8 and slips West or East with probability 0.1 each. From its current square, both North and West are walls, while East is open. What probability does the transition model assign to staying in the current square?
  1. 0.80
  2. 0.90
  3. 0.10
  4. 1.00
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A discounted episodic task has two actions from S: Early earns 4 and terminates; Late earns 0, then earns 9 and terminates one step later. At discount 0.5, a shaping potential is 0 at every nonterminal state and 10 at every terminal state. What action becomes best after adding γΦ(s′)−Φ(s)?
  1. Late, with shaped return 9.5 instead of Early’s 9.
  2. Late, with shaped return 4.5 instead of Early’s 4.
  3. Early, with shaped return 9 instead of Late’s 7.
  4. Early, with shaped return 14 instead of Late’s 9.5.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An action-value table gives Qπ(S,a)=5 and Qπ(S,b)=7 for a specified continuation policy. What does the second value mean?
  1. Take b once, then follow the specified policy; expected return is 7.
  2. Take b at every later state; expected return is 7.
  3. Take the policy’s action now, then b forever; expected return is 7.
  4. Take b once, then act optimally; expected return is 7.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A deterministic task has discount 0.5. At A, Exit earns 4 and terminates; Move earns 1 and reaches B. At B, Collect earns 8 and terminates. From zero, what does A’s first value-iteration value become, and what action does a greedy lookahead from that first array choose?
  1. First value 4; greedy action Exit.
  2. First value 5; greedy action Move.
  3. First value 8; greedy action Collect.
  4. First value 4; greedy action Move.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Two actions tie for the highest lookahead value during a policy-improvement step. The current action is one of them. How should tie handling support a reliable stopping test?
  1. Keep the current action so equal values do not cause switching.
  2. Alternate the tied actions to ensure every policy is evaluated.
  3. Always replace the current action so improvement remains strict.
  4. Lower the current action’s reward so the tie cannot recur.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A fixed recorded policy never selected Repair in state Worn. A model-based learner now wants to compare Repair with Run in Worn using only empirical transition counts. What information is missing?
  1. The successor distribution for Worn–Repair must equal Run’s.
  2. The discount factor for Worn–Repair must be set to zero.
  3. The successor distribution for Worn–Repair is unestimated.
  4. The value of Worn–Repair must equal its observed trial count.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A linear Q-model has weights (2,−1) and current features (1,2). The next state is terminal and the observed reward is 3. After a Q-learning weight update at rate 0.1, what value does the model assign to another pair with features (1,0)?
  1. 0.30
  2. 2.30
  3. 3.00
  4. 3.50
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Two bandit arms each have sample mean 0.5. Arm A has 18 pulls and B has 2. UCB1 selects B, and its next reward is 0. What is B’s new sample mean, and which arm does UCB1 select on the following decision?
  1. Mean about 0.33; choose A.
  2. Mean about 0.17; choose B.
  3. Mean about 0.50; choose A.
  4. Mean about 0.33; choose B.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A linear Q-model has a feature whose value is zero for the observed state–action pair. What happens to that feature’s weight during the update from this sample?
  1. It stays unchanged because the adjustment is multiplied by zero.
  2. It becomes zero because inactive features erase their weights.
  3. It increases by the full TD error without learning-rate scaling.
  4. It moves halfway toward the largest next-state action value.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Solve, diagnose, and transfer10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An action earns −6 and enters a terminal state. What reward remains in the action’s return after accounting for termination?
  1. The −6 transition reward, with zero continuation.
  2. Zero reward, because a terminal state has value zero.
  3. The −6 reward plus repeated terminal penalties.
  4. The −6 reward discounted once before it is received.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A task with one nonterminal state has two actions: Steady earns 3 and returns to the same state; Finish earns 8 and terminates. For what discount range within 0≤γ<1 is choosing Steady forever strictly better than choosing Finish immediately?
  1. 0≤γ<0.375
  2. 0≤γ<0.625
  3. 0.375<γ<1
  4. 0.625<γ<1
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A continuing discounted task adds the same constant 2 to every transition reward. The state dynamics and discount remain fixed. What happens to optimal action choices?
  1. They favor immediate termination because the offset is paid once.
  2. They remain optimal because every policy gains the same return offset.
  3. They favor actions with more possible successors because offsets add.
  4. They reverse because positive rewards become more important than costs.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An optimal Q-table at S has a tied maximum: a and b are both 6, while c is 2. What are V∗(S) and the allowed deterministic optimal action choices?
  1. Value 12; both a and b must be taken together.
  2. Value 6; a, b, or c can be chosen.
  3. Value 6; either a or b can be chosen.
  4. Value 4.67; actions must be sampled equally.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A proposed value function assigns V(S)=10. At S, action a earns 2 and returns to S; action b earns 3 and terminates. At discount 0.8, what conclusion follows when the optimality equation is checked at S?
  1. The equation fails because b has a larger immediate reward.
  2. The equation holds at S, with a greedy and b inferior.
  3. The equation holds at S, with b greedy and a inferior.
  4. The equation fails because both action values must equal 10.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A fixed policy in state A earns 1 and reaches B. In B it earns 4, then returns to A with probability 0.5 or terminates with probability 0.5. At discount 0.5, what are the policy values of A and B?
  1. V(A)≈3.43, V(B)≈4.86
  2. V(A)=3.00, V(B)=4.00
  3. V(A)=4.00, V(B)=6.00
  4. V(A)≈2.29, V(B)≈4.57
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Two synchronous value-iteration runs target value error below 0.03. Run A has discount 0.75 and largest final sweep change 0.008. Run B has discount 0.95 and largest final sweep change 0.002. What does the standard contraction-based error bound certify for their new arrays?
  1. Both runs; the bounds are 0.008 and 0.002.
  2. Only B; the bounds are 0.032 and 0.002.
  3. Neither run; the bounds are 0.032 and 0.040.
  4. Only A; the bounds are 0.024 and 0.038.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A continuing task has states Warm and Cold, with discount 0.5. In Warm, Stay earns 2 and returns to Warm; Shift earns 0 and reaches Cold. In Cold, Heat earns −1 and reaches Warm; Run earns 3 and returns to Cold. Exact policy iteration starts with Stay in Warm and Heat in Cold. What are the final values and the final action in Cold?
  1. V(Warm)=4, V(Cold)=1; Heat.
  2. V(Warm)=4, V(Cold)=3.5; Run.
  3. V(Warm)=4, V(Cold)=6; Run.
  4. V(Warm)=3, V(Cold)=6; Run.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A linear Q-model has weights (1,2). At state X, actions a and b have features (1,0) and (0,1). A different terminal transition has current features (1,1) and reward 0. With learning rate 0.5, what Q-learning weight update results, and what greedy action does X choose afterward?
  1. Weights (−0.5,0.5); X chooses b.
  2. Weights (0.5,1.5); X chooses b.
  3. Weights (−0.5,−0.5); X has a tie.
  4. Weights (1,2); X chooses b.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A completed episode visits S, then T, then S again, then terminates, with rewards 2, 4, and 6. At discount 0.5, what every-visit direct-evaluation estimate does this single episode give for S?
  1. 5.50
  2. 6.00
  3. 4.00
  4. 5.75
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

75 Key Terms, each with its definition

A

Action
An action is a choice available to the agent in its current state that determines a distribution of possible next states and rewards.
The action of working exposes a low-battery robot to both successful continuation and terminal failure.
Action value
An action value, or Q-value, is the expected discounted return after fixing the first action and using a stated continuation policy.
The optimal action value of working on a low battery includes the possibility of surviving and choosing to charge afterward.
Active learning
Active learning in reinforcement learning includes choosing actions to discover and improve the policy, as well as estimating returns.
Active learning can try an action such as working despite a low initial estimate to find out whether its current preference is wrong.

B

Bellman backup
A Bellman backup recalculates a value from immediate rewards and stored successor estimates, using either a fixed action or an optimal choice.
A Bellman backup at a low-battery state compares the risky expectation of working with the return available from charging.
Bellman equation
A Bellman equation relates a value to the expected immediate reward plus discounted continuation value after the next transition.
For a robot that works on a low battery, the Bellman equation includes the branch where work succeeds and the penalty when the battery fails.
Bellman optimality equation
A Bellman optimality equation equates a state’s optimal value with the largest expected reward-plus-continuation total among its actions.
For a high-battery state, the Bellman optimality equation compares the complete expectation of working with that of charging.
Bootstrapping
Bootstrapping improves one estimate using another current estimate, permitting learning before the full future return is observed.
Bootstrapping passes information backward as later visits use improving estimates of successor states.

C

Continuing task
A continuing task permits interaction to continue indefinitely without requiring a terminal state that ends each run.
Ongoing machine maintenance is a continuing task when even a broken machine can be repaired.
Contraction
A contraction reduces the maximum distance between value arrays by a factor below 1, supporting convergence to a unique fixed point.
At discount 0.9, the contraction bounds each new maximum value error by 0.9 times the old error.

D

Deep reinforcement learning
Deep reinforcement learning uses neural networks within reinforcement learning to learn representations or predictions for complex inputs.
Deep reinforcement learning can estimate game action values from pixels instead of a small hand-built state table.
Direct evaluation
Direct evaluation estimates a fixed policy’s state values by averaging discounted returns observed after visits in completed episodes.
Direct evaluation can give negative sample averages after two short runs even when a state’s true value is positive.
Discount factor
A discount factor is a number between 0 and 1 that multiplies the weight of rewards for each additional step into the future.
A discount factor of 0.9 leaves a reward ten steps later with about 0.35 of its original weight.
Discounted return
A discounted return is the sum of a run’s rewards after weighting each reward by a power of the discount corresponding to its delay.
A run’s discounted return changes if its large final reward arrives later while its earlier costs stay fixed.
Dynamic programming
Dynamic programming solves repeated subproblems by storing and reusing their results, as MDP methods reuse values across recurring states.
Dynamic programming reuses a state’s stored value whenever a possible robot path returns to that state.

E

Episodic task
An episodic task organizes interaction into runs that end at terminal states, after which a new run can begin from a start state.
A robot’s battery-failure trial is an episodic task when a battery failure ends that trial.
Epsilon-greedy selection
Epsilon-greedy selection chooses a random action with probability epsilon and otherwise chooses an action with the largest current value.
Epsilon-greedy selection can choose the same action through its random branch and its greedy branch.
Every-visit evaluation
Every-visit evaluation includes the return following each visit to a state, including repeated visits within the same episode.
An episode that visits the same state twice contributes two separate returns for that state to every-visit evaluation.
Expectimax tree
An expectimax tree alternates the agent’s action choices with probability-weighted chance outcomes to describe expected returns.
An expectimax tree displays a recurring state such as a high battery level repeatedly, while an MDP solver reuses one stored value for that state.
Exploitation
Exploitation chooses an action with the best current estimated return, using knowledge already gathered to collect reward.
Exploitation selects the largest estimated Q-value in the robot’s current battery state.
Exploration
Exploration selects actions to gain information about their outcomes and returns, including actions whose current estimates are lower.
Exploration can test a little-used route whose early unlucky outcomes caused an underestimated value.
Exploration function
An exploration function adjusts action scores using information such as visit counts to encourage choices that need more evidence.
An exploration function can give a little-tried action a higher score than a better-estimated action.

F

Feature
A feature is a numerical property of a state–action pair used by an approximate value model to distinguish situations and predict return.
A distance-to-charger feature helps predict whether working at the robot’s current location is worthwhile.
Finite horizon
A finite horizon limits the remaining number of decision opportunities, making the time left relevant to the best action in a state.
With a finite horizon of one step, a worn machine cannot recover a repair cost through later production.
First-visit evaluation
First-visit evaluation uses only the first visit to each state within each episode when collecting returns for its value estimate.
A second visit to the same state in one episode contributes no additional return for that state under first-visit evaluation.
Function approximation
Function approximation represents values through a parameterized prediction rule that can share information across many states or state–action pairs.
Function approximation gives many robot trips shared weights instead of a separate entry for each trip.

G

Generalization
Generalization transfers the effect of learning to other situations through shared features or parameters, including situations not yet visited.
Generalization changes predictions for unvisited trips when an update adjusts a weight those trips share.
GLIE
GLIE means greedy in the limit with infinite exploration: action selection becomes greedy while every relevant pair keeps receiving visits.
A schedule fails GLIE if it eventually stops trying a useful reachable action, even when epsilon approaches zero.
Greedy action
A greedy action attains the largest current action-value estimate in its state; it need not be truly optimal while estimates are inaccurate.
Charging can appear to be the greedy action after early bad luck makes the estimated value of working too low.

I

In-place update
An in-place update immediately stores a new value so that later backups in the same sweep may read that newly computed estimate.
An in-place update to one state’s value can affect another state’s calculation later in the same sweep.
Indicator feature
An indicator feature takes value 1 for a specified condition and 0 otherwise; one indicator per state–action pair reproduces a Q-table.
An indicator feature for working on a high battery is zero for charging on a low battery, leaving that other pair untouched by its weight.

L

Learning rate
A learning rate controls how much a value or weight changes in response to new evidence, balancing adaptation against sample noise.
A learning rate of 0.5 moves a table entry halfway from its old estimate toward the latest target.
Linear Q-approximation
A linear Q-approximation represents an action value as a weighted sum of features, with weights learned from observed prediction errors.
A linear Q-approximation adds the contributions of battery and distance features to predict an action value.
Living reward
A living reward is a reward received on nonterminal steps that changes the incentive to continue acting or to reach an ending sooner.
A large negative living reward can make a nearby unfavorable exit preferable to a lengthy route.

M

Markov decision process
A Markov decision process is a model of repeated choices in which observable states, actions, transition probabilities, and rewards describe the task.
The robot’s Markov decision process describes how working and charging affect battery states and rewards.
Markov property
The Markov property means that the current state and action contain the relevant history needed to predict the next outcome.
A position-only model breaks the Markov property when different velocities predict different next positions.
Model-based learning
Model-based learning estimates transition and reward behavior from data and uses that estimated model to plan decisions.
Model-based learning turns counts of a work action’s outcomes into a transition model that value iteration can solve.
Model-free learning
Model-free learning estimates values or action values directly from experience without first building an explicit transition model.
Model-free learning changes a Q-value from a sampled transition without first estimating its probability.
Modified policy iteration
Modified policy iteration interleaves policy improvement with a limited number of evaluation sweeps instead of fully evaluating each policy.
Modified policy iteration reduces evaluation work in a round by improving before all values have converged.
Multi-armed bandit
A multi-armed bandit is a repeated single-state choice among actions with unknown reward distributions and no state-transition planning problem.
A multi-armed bandit models repeated choices among fixed reward sources without travel between states.

O

Off-policy learning
Off-policy learning learns about a target policy that can differ from the behavior policy responsible for collecting experience.
Q-learning illustrates off-policy learning when its target is greedy but its action-selection rule explores.
Offline reinforcement learning
Offline reinforcement learning learns values or policies from previously recorded experience without collecting fresh interactions during training.
Offline reinforcement learning can use an existing robot log, but its untried actions still lack data.
On-policy learning
On-policy learning estimates returns for the behavior policy itself, including the effects of any exploratory choices it makes.
On-policy learning can account for accidental exploratory moves when an agent chooses a route near a cliff.
One-step lookahead
A one-step lookahead scores each action using its immediate rewards, successor probabilities, and a stored estimate of future state values.
A one-step lookahead compares a low-battery robot’s actions using their rewards and the values of the high-battery and failed states.
Optimal policy
An optimal policy achieves the highest expected return from every state; several policies may be optimal when action values tie.
A robot’s optimal policy chooses to charge a low battery even though charging has no immediate positive reward.

P

Passive learning
Passive learning estimates how well a fixed policy performs while leaving that policy’s action choices unchanged during evaluation.
Passive learning follows a supplied charging policy while estimating the return of each battery state.
Planning
Planning computes values or policies using a transition and reward model, whether that model was supplied in advance or learned from experience.
A controller repeats planning after its learned failure probabilities change with additional experience.
Policy
A policy is a rule for choosing actions from states, either by selecting an action directly or by assigning probabilities to available actions.
A robot’s policy prescribes working when its battery is high and charging when it is low, whatever path led to that battery level.
Policy evaluation
Policy evaluation computes the expected return of a fixed policy at each state, without changing the policy to improve its actions.
Policy evaluation of an always-work policy reveals the long-run cost of repeatedly risking failure on a low battery.
Policy improvement
Policy improvement chooses actions with the best lookahead under the evaluated policy values, producing a policy at least as good.
Policy improvement switches a low-battery robot to charging when charging’s lookahead of 7.45 beats the old value of working, −3.48.
Policy iteration
Policy iteration alternates evaluating a policy and choosing better actions using those values until the policy stops changing.
Policy iteration first changes a robot’s low-battery action from working to charging, then evaluates the new policy and checks again.
Policy search
Policy search adjusts the parameters of a policy directly to improve measured return, instead of first requiring learned action values.
Policy search compares revised controllers by their measured returns while adjusting the controllers directly.
Potential-based shaping
Potential-based shaping adds discounted next-state potential minus current potential, preserving optimal policies under the needed boundary conditions.
Potential-based shaping sets episodic terminal potentials to zero so endings gain no leftover shaping value.

Q

Q-learning
Q-learning updates an action value toward an observed reward plus the discounted largest next-state action value.
Q-learning moves the entry for working on a low battery toward the failure penalty when that choice makes a robot’s battery fail.

R

Regret
Regret is the cumulative reward shortfall relative to optimal choices over the same period, commonly evaluated as an expected quantity.
Fixed random exploration accumulates regret when it repeatedly chooses an arm with lower true mean reward.
Reinforcement learning
Reinforcement learning learns values or behavior from experienced transitions and rewards in a sequential decision problem.
A robot uses reinforcement learning when observed successes and failures teach it which actions pay off.
Reward function
A reward function assigns an immediate numerical payoff to a transition, with negative numbers representing costs or undesirable outcomes.
A robot’s reward function assigns −10 to a transition in which working on a low battery ends in failure.
Reward hacking
Reward hacking occurs when an agent increases its specified reward through behavior that fails to achieve the designer’s intended objective.
A robot spilling and recollecting dirt to earn repeated collection rewards illustrates reward hacking.
Reward shaping
Reward shaping adds feedback to the task reward to guide learning; poorly chosen additions can change which behavior is optimal.
Poor reward shaping can encourage a bonus-earning loop that keeps an agent away from its intended goal.

S

SARSA
SARSA updates the current action value using the reward and value of the actual next state and next action selected by the behavior policy.
SARSA uses the low-valued next action actually selected by exploration instead of a higher unchosen value.
Sparse reward
A sparse reward provides feedback only on rare events, such as reaching a goal, leaving many earlier actions without direct success feedback.
A navigation learner with a sparse reward may make many unsuccessful trips before its first goal payoff.
State
A state is the information describing the agent’s current situation that is needed to predict the outcomes and rewards of available actions.
A robot’s state distinguishes a high from a low battery level because working carries different risks at each level.
State representation
A state representation specifies which observable variables distinguish situations for predicting action outcomes and rewards.
Adding battery level to a state representation distinguishes equally located robots with different failure risks.
State value
A state value is the expected discounted return from a state when the agent follows a specified policy from that point onward.
A robot’s high-battery state value is much lower under a policy of always working than under a policy that charges when the battery is low.
Stationary policy
A stationary policy uses the same action rule whenever a state occurs, without changing that rule according to the decision time.
A stationary policy gives a low-battery state the same action at every visit, even if the previous trip was unusually long.
Stochastic policy
A stochastic policy assigns probabilities to the actions available in a state, allowing repeated visits to produce different choices.
An epsilon-greedy stochastic policy assigns positive probability to actions beyond the current best one.
Synchronous sweep
A synchronous sweep computes all new state values from the same previous array, then makes the completed array available for later updates.
A synchronous sweep reads one state’s old value when updating another state, even if that state’s new value was computed first.

T

Tabular representation
A tabular representation stores a separate adjustable value for each state or state–action pair, without sharing weights across entries.
A tabular representation leaves the entry for one state–action pair unchanged when a sample directly updates only another pair’s entry.
TD error
A TD error is the difference between a reward-plus-discounted-successor target and the current estimate being updated.
A target of 11.2 and current estimate 10 produce a TD error of 1.2 for the observed transition.
Temporal-difference learning
Temporal-difference learning updates a state value toward an observed reward plus a discounted estimate of its successor’s value.
Temporal-difference learning updates a state’s value on arrival at the next state without waiting for a robot’s run to end.
Terminal state
A terminal state ends an episode and has zero future return, although the reward on the transition into it remains part of the return.
A robot’s battery-failure state is a terminal state: the robot receives a penalty on entering it and then earns no additional rewards.
Tie handling
Tie handling determines which maximizing action is retained when several actions have equal scores, avoiding unnecessary policy changes.
Stable tie handling keeps an equally good current action so the unchanged-policy test can recognize stability.
Transition model
A transition model assigns a probability to each possible successor for a state–action pair, with the probabilities in that row summing to 1.
For a robot that works with a high battery, a transition model assigns 0.7 to staying high and 0.3 to reaching low.

U

UCB1
UCB1 chooses a bandit arm by adding a count-based confidence bonus to its sample mean after every arm has been tried once.
UCB1 can select a lower-mean arm because its smaller sample count creates a larger confidence bonus.

V

Value iteration
Value iteration repeatedly applies optimality backups to state values, then extracts a policy from the resulting action expectations.
Value iteration propagates the benefit of charging a low battery as its planning horizon grows across sweeps.
Value-error bound
A value-error bound limits how far estimated state values can be from optimal values, using the discount and a measured backup change.
A value-error bound scales a small sweep change before it certifies the desired accuracy of the values.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started