In the Reinforcement Learning book (Prof. Sutton et al.) the authors explain a few basic algorithms of Reinforcement Learning. A particular kind of algorithms called n-step Temporal Difference Learning algorithms use the following formula for their updates for actions-value function:
$$ Q_{t+n}(S_t,A_t) = Q_{t+n-1}(S_t,A_t) + \alpha \rho(G_{t:t+n} - Q_{t+n-1}(S_t,A_t)) $$ where $$ \textrm{for ordinary SARSA:} \quad$$ $$ G_{t:t+n} = \sum_{k=t}^{min(t+n,T)-1} \gamma^{k-t} R_{t+1} + \gamma^n Q_{t+n-1}(S_{t+n},A_{t+n}) $$ $$\\ \rho = \prod_{k=t+1}^{min(t+n,T)-1}\frac{\pi(A_k|S_k)}{ b(A_k|S_k)} $$ $$\textrm{ for Expected SARSA:} \quad$$ $$ G_{t:t+n} = \sum_{k=t}^{min(t+n,T)-1} \gamma^{k-t} R_{t+1} + \gamma^n \sum_{a}{\pi(a|S_{t+n})Q_{t+n-1}(S_{t+n}, a)} $$
$$\rho = \prod_{k=t+1}^{min(t+n-1,T)-1}\frac{\pi(A_k|S_k)}{ b(A_k|S_k)} $$
Although the authors do a very good job explaining the algorithms, there is still something that escapes from my understanding. What is the rationale for the different time limits for Importance Sampling ratio expression $\rho: \{t+1,\dots,t+n-1\}$ and $\rho: \{t+1,\dots,t+n-2\}$?
Importance sampling as I could understand would compensate the fact of sampling from a different distribution by factoring the return by relative probability of observing the experience sequence (only as far as the rewards were sampled) under target and behaviour policy. As the effective actions sampled for a state-action pair $S_t,A_t$ for n-step SARSA and Expected SARSA are the same (meaning the actions that were used to generate rewards), the only difference between them is the way they use estimates of $Q_{t+n}$.
But how one would understand the difference of the involved importance samling rations $\rho: \{t+1,\dots,t+n-1\}$ and $\rho: \{t+1,\dots,t+n-2\}$ when the both algorithms use the same experience for their updates?
Even if we assume that the last step $A_{t+n}$ in the Expected SARSA should not count in the $\rho$ formula, then that would only affect the factor $\frac{\pi(A_{t+n}|S_{t+n})}{ b(A_{t+n}|S_{t+n})}$, and not the one with $t+n-1$ that was removed.