Answers.Body: <blockquote>
  <p>However, from the blogs and texts I read, the equations are expressed in terms of V and NOT Q. Why is that?</p>
  </blockquote>
  <p>MC and TD are methods for associating value estimates to time step based on experienced gained in later time steps. It does not matter what kind of value estimate is being associated across time, because all value functions are expressing the same thing in general, which is the <em>expected return</em> conditioned on a &quot;current position&quot; within the MDP. In MC the association is directly with a sampled return, in TD with a sampled combination of immediate reward and a later value estimate - most commonly in TD the same kind of value estimate (e.g. matching later state value estimates to state values).</p>
  <p>Both approaches can be analysed and used from the perspective of both state value (V) and action value (Q) functions. They also apply to other value functions - e.g. afterstate values.</p>
  <p>It is quite common for textbooks and tutorials to use the slightly simpler state value function to explain how MC or TD learning work in general, outside of being used for any purpose. You can also use the state value function for model-free <em>policy evaluation</em> in MC and TD.</p>
  <p>However, without a model, you cannot use state value function for control (i.e. to learn an optimal policy). To pick the best action using state values, you need to do something like this:</p>
  <p><span class="math-container">$$\pi(s) = \text{argmax}_a [ \sum_{r,s'} p(r,s'|s,a)(r + \gamma v(s'))]$$</span></p>
  <p>The problem here is that <span class="math-container">$p(r,s'|s,a)$</span> is a model of the environment. So, if it is needed, the control method would not be model-free.</p>
  <p>Hence when you learn about MC or TD in a <em>control</em> scenario, model-free methods to learn optimal policies, then you generally <em>need</em> to use an action value (sometimes you can use an afterstate value, if the action involves choosing the next state directly).</p>
  <p>With an action value function, the greedy policy becomes:</p>
  <p><span class="math-container">$$\pi(s) = \text{argmax}_a q(s, a)$$</span></p>
  <p>This does not refer to any model of the environment. So it can be used when you have none.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-23T08:39:21.460Z
Answers.LastActivityDate: 2020-11-23T13:37:23.667Z
Answers.LastEditDate: 2020-11-23T13:37:23.667Z
Answers.UserDisplayName: Neil Slater
Body: <p>Both MC and TD are model-free and they both follow a sample trajectory (in the case of TD, the trajectory is cut-short) to estimate the return (we basically are sampling Q values). Other than that, the underlying structure of both algorithms is exactly the same. However, from the blogs and texts I read, the equations are expressed in terms of V and NOT Q. Why is that?</p>
  
Tags: <reinforcement-learning><monte-carlo-methods><temporal-difference-methods><value-functions><return>
Title: Is the expected value we sample in TD-learning action-value Q or state-value V?
UserDisplayName: Aung Khant
ThreadText: # Is the expected value we sample in TD-learning action-value Q or state-value V?
  
  (Asked by: username_0 on 2020-11-23)
  
  Both MC and TD are model-free and they both follow a sample trajectory (in the case of TD, the trajectory is cut-short) to estimate the return (we basically are sampling Q values). Other than that, the underlying structure of both algorithms is exactly the same. However, from the blogs and texts I read, the equations are expressed in terms of V and NOT Q. Why is that?
  
  **Tags:** reinforcement-learning, monte-carlo-methods, temporal-difference-methods, value-functions, return
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-23. Score: 3 | Accepted answer
  
  > However, from the blogs and texts I read, the equations are expressed in terms of V and NOT Q. Why is that?
  
  MC and TD are methods for associating value estimates to time step based on experienced gained in later time steps. It does not matter what kind of value estimate is being associated across time, because all value functions are expressing the same thing in general, which is the *expected return* conditioned on a "current position" within the MDP. In MC the association is directly with a sampled return, in TD with a sampled combination of immediate reward and a later value estimate - most commonly in TD the same kind of value estimate (e.g. matching later state value estimates to state values).
  
  Both approaches can be analysed and used from the perspective of both state value (V) and action value (Q) functions. They also apply to other value functions - e.g. afterstate values.
  
  It is quite common for textbooks and tutorials to use the slightly simpler state value function to explain how MC or TD learning work in general, outside of being used for any purpose. You can also use the state value function for model-free *policy evaluation* in MC and TD.
  
  However, without a model, you cannot use state value function for control (i.e. to learn an optimal policy). To pick the best action using state values, you need to do something like this:
  
  $$\pi(s) = \text{argmax}\_a [ \sum\_{r,s'} p(r,s'|s,a)(r + \gamma v(s'))]$$
  
  The problem here is that $p(r,s'|s,a)$ is a model of the environment. So, if it is needed, the control method would not be model-free.
  
  Hence when you learn about MC or TD in a *control* scenario, model-free methods to learn optimal policies, then you generally *need* to use an action value (sometimes you can use an afterstate value, if the action involves choosing the next state directly).
  
  With an action value function, the greedy policy becomes:
  
  $$\pi(s) = \text{argmax}\_a q(s, a)$$
  
  This does not refer to any model of the environment. So it can be used when you have none.
  
  
  ---
  
  