Action-value methods, non-stationary bandits, UCB, and gradient bandits.
Chapter 2 studies action-value methods and the exploration-exploitation tradeoff in the k-armed bandit setting.
Exercise 2.1
P(optimal)=(1−ϵ)+nϵ=0.5+0.5∗21=0.5+0.25=0.75
Exercise 2.2
Time Step
Action Taken
Reward
Q(1)
Q(2)
Q(3)
Q(4)
Greedy Action(s)
0
-
-
0
0
0
0
-
1
1
-1
-1
0
0
0
1, 2, 3, 4
2
2
1
-1
1
0
0
2, 3, 4
3
2
-2
-1
-1/2
0
0
2
4
2
2
-1
1/3
0
0
3, 4
5
3
0
-1
1/3
0
0
2
At time steps 4 and 5, a non-greedy action was selected. Therefore, those selections were definitely random.
At time steps 1, 2 and 3, the action selected could've been greedy or random. Therefore, the actions are possibly random.
Exercise 2.3
For ϵ=0.1,
P(optimal)=(1−ϵ)+nϵ=0.9+100.1=0.91
For ϵ=0.01,
P(optimal)=(1−ϵ)+nϵ=0.99+100.01=0.991
Therefore, in the limit, the probability of selecting the optimal action is higher if we select ϵ=0.01 even though in the shorter term ϵ=0.1 starts finding the optimal action sooner.
And since the expected reward is given by
E[R]=P(optimal)⋅μ∗+(1−P(optimal))⋅μˉother
The expected reward will be higher for the action that gets selected more often in the longer run. Therefore, the expected reward for ϵ=0.01 will be higher.
Constant step-size updates adapt more quickly than sample averages when the reward distribution changes over time.
As we can see from the results above, the constant step-size agent performs better than the sample average agent when the bandit is non-stationary.
Exercise 2.6
The optimistic initial values force the agent to explore more in the start. The agent cycles through all possible actions, most of which aren't optimal actions.
During this exploration, we sometimes discover optimal actions leading to a big spike. However, this is usually followed by suboptimal actions which is why we see such oscillatory behavior.
Exercise 2.7
In Solution 2.4, the weight on Q1 stays non-zero, which is the cause of the bias. We need to show that by using βn instead of a constant step size, the weight on Q1 is zero.
With some simple derivation, this can be rewritten as
oˉn=1−(1−α)n
So,
βn=1−(1−α)nα
And,
1−β1=1−1−(1−α)α=1−1=0
Since the weight on Q1 includes this term, it turns out to be zero and Q1 is thus cancelled out and we are left with:
Qn+1=i=1∑n(βij=i+1∏n(1−βj))Ri
Exercise 2.8
For the first 10 timesteps, the UCB algorithm samples each action once.
After this, it samples according to
At=argamax[q^t(a)+cNt(a)lnt]
For the 11th timestep, the bonus term is identical for all actions c1ln11 and therefore the single-sample greedy action is selected. This action happened to return a high reward leading to a jump.
However, at the next time step, N(a) increased to 2 for this action, whereas it stayed at 1 for all the other actions. This made the algorithm re-explore many of those under-sampled arms.
This short-run extra exploration lowers the subsequent average reward, so the curve drops after the spike and then recovers as estimates improve.
A larger c leads to more exploration. With c=1, the exploration is weaker, so the post-spike dip is smaller and the spike is less prominent.
Exercise 2.9
For two actions, we can write the softmax function as