# Basics

## Introduction

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-3cf22dc655067c8e96dbc9689874bd37061a86c4%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-ba2a8addbff09603699ca027c8f4eb43642c5840%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-77899ab061e7a48ea7cbe2391cfc24a71bcac333%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-10b10d08dbba10838b4670d05a0c2a09bc9ad94a%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-95e7546c1d8978bfb767335bb3ef309e80f444aa%2Fimage.png?alt=media)

## Action, Reward, Policy

### Reward

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e2fdb3d5c3f3658847297e13a3a704facd86b9fc%2Fimage.png?alt=media)

#### Cumulative Reward

Maximize the expected(upcoming future) cumulative reward. What is and how to get the future or expected reward?

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e6d9157c1994c8633d9b17f00f30004804d6bc05%2Fimage%20\(129\)%20\(2\)%20\(2\)%20\(2\)%20\(3\).png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-11fef9e8ad735dfb4e2fb4afaba228b05f5c6ca2%2Fimage.png?alt=media)

#### Discounted return

The agent tries to select actions so that the sum of the discounted rewards it receives over the future is maximized.

Discounted rate: \[0,1] give more weight to current or immediate rewards. User design. It can be used to set limits of rewards not looking too far in continuous tasks.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e6b77b0112ccc72c0784f8b1b59a962aee52f7a3%2Fimage.png?alt=media)

### MDP: Markov Decision Process

MDP: Reinforcement framework. It works on both continuing and episodic task.

If the state signal has the Markov property, on the other hand, then the environment's response at t+1 depends only on the state and action representations at t, in which case the environment's dynamics can be de ned by specifying only

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e7c613ad40d122251f73ce21c2c262b7a5a0ea80%2Fimage.png?alt=media)

One-step Dynamics

* The environment considers only the state and action at the previous time step (S\_t, A\_t) at time t+1.
* It does not care what States and Actions were more than one step prior.
  * {S\_0 ... S\_(t-1) }, {A\_0 ... A\_(t-1) }
* It does not consider any previous rewards of to respond to the agent.
  * {R\_0 ... R\_(t) }
* The environment decides the state and reward by

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-9a4ed0c4a3b70b985424971ad5299f50d4c0d05b%2Fimage.png?alt=media)

#### Pole-cart example

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-edbb2c4c06a20c856c2d41517067347d08a020ea%2Fimage.png?alt=media)

It is an MDP problem, but not finite MDP. The environment considers only the current action and states not the previous ones to get the next reward.

* Actions: 2 control input
  * move left
  * move right
* State: there are 4 observations
  * Cart position, cart velocity
  * Pole angle, Pole velocity
* Reward:
  * Not fall +1, fall -1

### Policy

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-a0e3e8b270407d2e7c809dc193120fa405782e80%2Fimage.png?alt=media)

Deterministic Policy

Stochastic Policy

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-9adce4c526d4e5f40a6d985340d1f43749b520d2%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-76178a9bb033357e6bc7e98b2db0766d295a12d2%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-a7fa0617b0e0487c597620e4587faf568bab4f21%2Fimage.png?alt=media)

### State-Value Function

#### Example: Episodic problem of finding the goal (deterministic policy)

The reward map

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-50aecf5c00a2ae304adc703a223166ad0f11f151%2Fimage.png?alt=media)

* Option 1: An example of a bad policy.
  * Starting at S(1,1) , cumulative reward score for this policy = -6
  * Starting at S(1,2) , cumulative reward score for this policy = -6

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-710ac3b940a9936ec32d8b11ce88e2ea96d34c4d%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-7215a441b739a32ba986251d06c32f473d27e008%2Fimage.png?alt=media)

*
  * For every other state for this bad policy .
  * This is a function of the environment state: State-Value Function
  * Each state has a value: Expected return by following this policy starting at that state
  *

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-3be2b7d6bb501c8c4fddacbf11db4d70bf84c1b3%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-3ad61bb32c44db3895a440a5fc50605c66bcb3f6%2Fimage.png?alt=media)

For the given policy, the state-value function starting in state 's' returns the 'expected' reward

If the policy changes, the state-value function changes.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-7f050c16ebe439b6c906a219127b38dbc35a5f8c%2Fimage.png?alt=media)

### Bellman Expectation Equation

In calculating for the values of state-value functions for given policy, we can effectively calculate the value of any state, using recursive property.

* Value of any state: You only need the immediate reward and the value of the state that follows
* > But in complicated worlds, the immediate reward and next state cannot be known with certainty.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-91f7ff94cb821168ed657cf171294ce54c096b56%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e2721565b1ce18febcf61bf83df111d0cf344c39%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-736f05dca8dc105d8c73590a0ada0ec5f7acca77%2Fimage%20\(146\)%20\(1\).png?alt=media)

### An Optimal Policy

Then, how to find the optimal policy? There are numbers of different policy. How can we define if one policy is better than the other?

* A better policy if **all** state has equal or better values
  * some policies may not be able to be compared
* Optimal policy may not be unique
* From the best value-state function

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-27e187cf16f9b38f544df282b70542b3bac17b31%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-db832895e93c44ed6356d76a89c757d219f0b4bd%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-6e1fd3985fe7641ff068185110bf439d741ffc47%2Fimage.png?alt=media)

### Action-Value function

At that state s, there could be multiple choices of action to take for the given policy.

The optimal action-value function is denoted as : q\*. It tells the best action to take for being in that state s.

#### Action-value vs State-value

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-3d6ca4615eca0e949edcbf98fadb108c11e1bf82%2Fimage%20\(167\).png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-6bb9e5ecac998b7c42e7f51dc8f0f85bf2379fea%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-f8ff9b01a30c96b82717276877ed1643ba3700fe%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-0ee7753e506988a408365aff7f551e43ff36111f%2Fimage.png?alt=media)

Example: starting at s(0,0), if action 'down' is chosen, then it follows the policy for all future time steps(rest states) to give the reward '0'. It can continue for all other starting states and the action it takes at that state.

* Starting in that state & taking the action --> follows the policy for the rest steps

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-6758a928bebfadef2be498a641eb4b9e67b6fe5c%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-0ad879d18045d17b4841e69d8ccf3b1c2841f38a%2Fimage.png?alt=media)

### Optimal Policy from Optimal action-value function

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-9d8da087fde718fee69b513066ec05c1c8535227%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e8e8c5523fd70153a95dbb954c75be0358eac0a7%2Fimage.png?alt=media)

#### Example:

That maximizes the action-value function for each state can be found from the table. The policy can give '1' probability to make sure this action is taken all the time.

There can be multiple actions as in S3: either a1 or a2. We can give probability p,q for each of them and '0' probability for the other actions.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-4dc0907dfaab6d4a9b2d924dc7938bad9129567c%2Fimage.png?alt=media)

## Value Iteration vs Policy Iteration

Assume an MDP small discrete state-action spaces. Given an MDP (S,A,P, R, gamma, H), find the optimal policy PI\*

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-4af83f1bcfa800fdee51a886e1b1132a88218ff3%2Fimage.png?alt=media)

#### Value Iteration

Iteratively update estimates of Q(s) and V(s) until they converge. Then, update the policy.

![Pseudo code for value-iteration algorithm. Credit: Alpaydin Introduction to Machine Learning, 3rd edition.](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e17d7c37b3ef04303bd386a16f539bf39cb27e4a%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-879f057353f72dee97bc0c9f37a8e4426c86c402%2Fimage.png?alt=media)

#### Policy Iteration

Policy can converge before the value function. Redefine the policy at each step. Repeat until policy converges

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-8fafd95b5a925269329d8f8aaf2fbc75615e76a3%2Fimage.png?alt=media)

## Monte Carlo

How to interact with the environment to find the optimal policy? Which action is the best from each state?

To gain the useful understanding of the environment, it needs many episodes of random actions.

#### Q-Table

Q(s,a), q values from the action-value functions for given policy.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-fad3ba017befa5a3a07e5e266bd6ae367f1777d2%2Fimage%20\(148\).png?alt=media)

#### MC Prediction

If the true action-value function is NOT known, we can predict (approximate) it with Q-tables from many episodes

It is estimating the q values of action-value function with a Q-table., with Monte Carlo approach.

In a single episode, the same action is selected from the same action multiple times.

* Every-visit MC Prediction: average the returns of all visits to each state-action pair
* First-visit MC Prediction: consider only the first visit to the state-action pair

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-c0849b28f82d5cce75094851dc538e891a3d4853%2Fimage.png?alt=media)

### Greedy Policy and Epsilon Greedy Policy

How to find an optimal policy from Q-table?

Construct the policy that is greedy for a better policy

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-0f6baa056346d05de1f13ee9c6b0017db73e7dad%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-1f094feb1b842df6535abf79e6bdde23ba4f2e1b%2Fimage.png?alt=media)

Greedy policy always select the greedy action But, we want to **explore** all other possibilities. To give a probility of epsilon in selecting other action than the greedy action, use:

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-e32f005377decc7b04c58d577bceb00869dbdd7b%2Fimage.png?alt=media)

### Exploitation - Exploration Dilemma

There is a trade-off between Exploitation and Exploration

* Exploitation: action based on past experience. trusting more on experience (epilon value is low)
* Exploration: select range of various possibilities (epsilon value is high)

Make sense to favor exploration over exploitation initially, when the environment is not fully known. As the policy gradually becomes more greedy, it make sense to favor exploitation over exploration

**GLIE (Greedy in the Limit with Infinite Exploration)**

* $e\_i > 0$ for all step i & $e\_i$ decays to zero as i approaches inf.

### When to update the Q-table?

* Conventionally, the Q-table is updated once after all the episode iterations & Q-table have converged.
* For more efficiency, update Q-table every episode iteration: **Incremental Mean**
* (1/N) can be tuned as alpha
  * $$\alpha$$ is large, trusting the most recent sampled(experienced) return $$G_t$$
    * focus on more recent experience
    * faster learning, but may not converge
  * if $$\alpha$$ is very low, tend not to update by the agent
    * considering the longer history of returns

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-60cafe371cdc0a7eebcd258371392a283d75f5b9%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-32a8dd1fe5d82f8db2a3b1d2db0efbb046ab04cd%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-406f95a9c1cea9c979225ee5b1918932652642aa%2Fimage.png?alt=media)

## Dynamic Programming

## TD Learning

TD learning is a combination of Monte Carlo ideas and dynamic programming (DP) ideas. Like Monte Carlo methods, TD methods can learn directly from raw experience without a model of the environment's dynamics. Like DP, TD methods update estimates based in part on other learned estimates, without waiting for a final outcome (they bootstrap).

> MC: update Q-table after an episode
>
> TD: update Q-table at every step, model-free,

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-6065c97fcd80b3b74f74b52d6b0541bc448e8b04%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-f14dee2a61f68d0d2427304672ac73a6e0c1e873%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-289ffbed1109465fc296b4dc3c50b6bd087315c8%2Fimage.png?alt=media)

### Sarsa(0), Q-Learning, Expected Sarsa

* Sarsa(0): Chooses the action A\_(t+1) by the policy, before updating Q(S\_t,A\_t)
  * On-policy, uses e-greedy policy
  * Better in online performance
* Saramax: Chooses the action a from all the possible actions for the state S\_(t+1), after updating Q(S\_t,A\_t)
  * Off-policy. Different from the e-greedy policy to select action
  * Chooses the action of state S\_(t+1) that gives the maximum q-value, after updating the Q-table at each step.
* Expected Sarsa: Considers the expectation of all possible actions for the state S\_(t+1).
  * On-policy
  * Better in online performance, usually better than Sarsa

These TD control algorithms are guaranteed to converge to optimal Q-table, as long as alpha is sufficiently small and GLIE (Greedy in the Limit with Infinite Exploration) is met.

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-880aff4a741e0822730f88b90d0eb56958ad4ca6%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-f0b1445551ba4c2d5ad25285f19f6bd12ebead4e%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-34184660f08030f4199a38bfb7e208418dde32ea%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-227d22cd4aee39c1cd49aa61dd04818048492f5b%2Fimage.png?alt=media)

![](https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-b0411dcde7fbe92a28fa46122ebc69cf84a0786b%2Fimage.png?alt=media)

## Resources

RL Cheat sheet- Udacity

{% file src="https://3698175758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAwtzMy_pbrChIExFtN%2Fuploads%2Fgit-blob-190da1ba51d51663c7f07fe4ed2de8ceca707f94%2Fcheatsheet.pdf?alt=media" %}

## QnA

Difference between max and argmax for f(x) , for x in domain D.

> max is the unique value of output(x): -x^2
>
> argmax is a set of values of x that give the maximum value: e.g. sinX
