Intro
RL is a framework for solving decision problems, by building agents that learn from the environment by interacting with it through trial and error and receiving rewards (positive and negative) as unique feedback
at each timestep t
agent recieves state S_t from environment
agent takes action A_t
environment transitions to next state S_t+1
environment provides a reward R_t+1
forms a loop: (s_t, a_t, r_t+1, s_t+1)
Reward hypothesis: agent’s goal is to maximize expected cumulative reward, aka expected return
Return Types
our agent only needs current state to decide what action to take and not the history of all states and actions they took before
P(s_t+1|s_t, a_t)
state S: is a complete description of the state of the world
action space: all possible actions in an environment
discrete space: number of possible actions is finite
continuous space: number of possible actions is infinite
Finite horizon undiscounted return:
sum of rewards obtained in a fixed window of steps
Infinite horizon discounted return:
sum of all rewards ever obtained by the agent
Cumulative return is like this..
R_t = r_t+1 + r_t+2 + r_t+3 + …
R = cumulative return
future rewards are uncertain, so we discount them
another reason for discounting is to ensure that the values don’t spin up to infinity in the longer run.
how to discount rewards?
apply discounting factor y [0, 1] at each reward typically 0.95-0.99
high y → agent cares about long term rewards
low y → agent cares about short term rewards
Discounted expected return:
task:
instance of reinforcement learning problem. types:
- episodic task: we have a starting and ending point
- continuing task: tasks that continue forever
Goal in reinforcement learning is to build an agent that selects actions which maximize expected cumulative (discounted) rewards. for this the agent must learn an optimal policy
Policy
function which outputs what action to take given a state
a policy can be deterministic or stochastic
Stochastic/categorical policies
is like a classifier over discrete actions, we build NN that inputs observation, convolutional or densly connected and have one final layer that gives logits for each action followed by a softmax to convert logits → probs
Stochastic/diagonal gaussian policies
a multivariate gaussian distribution is described by a mean vector and covariance matrix. if we opt for a diagonal gaussian distribution covariance matrix would only have a diagonal filled, as a result we can represent it as a columnar vector
ways in which we can express covariance matrix:
- single vector of standard deviations representing actions
- a nn that inputs states to log std of actions
to sample we can use the mean and the std of state + a little noise

Value functions
instead of learning a policy directly, learn a value function
value of a state/action means: if i start here and act optimally, how much total reward can i expect in the future?
requires computation of all state action pairs and picking the most valuable one, compute expensive
outputs how valuable a state is.
- state value function V(S)
- Action value function Q(s,a)

all value functions obey self-consistency bellman equations. idea is: ‘the value of your stating popint is the reward youp expect to get from being there, plus the value of wherever you land next’
in both the policy is derived from the value, its not learned directly
some strategies to train our value/policy function
- monte carlo: learn after a full episode, use actual return to update the value function
start an episode at a given state
agent takes actions using a policy
wait until episode ends
calculate total return for each state
update value function - temporal difference learning (TD) : learn after each step estimate return using immideat reward + value of next state