Raj-Ghugare
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
PAC bandits === Author [Raj Ghugare](https://github.com/Raj19022000) ###### tags: `notes` `multi-armed bandits` `PAC` Topic of discussion: [PAC Bounds for Multi-Armed Bandit and Markov Decision Process](https://link.springer.com/chapter/10.1007/3-540-45435-7_18) ## Review and research notes ### Introduction * The motivation for this paper was to provide a novel way of solving the immediate RL problem of Multi-armed bandits with a better sample complexity(number of time steps the agent takes to return an arm). * *What exactly does it mean to get to an optimal solution of multi armed bandit problem?* This paper addresses a Probably Approximately Correct(PAC) way to solve the problem. * Given an ($\epsilon$,$\delta$) pair, the agent should return an arm with a guarantee that the value of that arm should be within $\epsilon$ limits of the value of the true best arm with a probability of 1-$\delta$.In mathematical terms $$pr[q_*(a) \geq q_*(a^*) - \epsilon] \geq 1 - \delta $$ where $\epsilon$,$\delta$ $\in [0,1]$ Where a is the action returned and $a_*$ is the most optimal action. $q_*(a)$ is the true value function. Before we start off with discussing the methods, lets get acquainted with the notations * $q_*(a)$ is the true value function of all arms. * $Q(a)$ is our empirical estimate of the true value function of all arms. * $k$ is the number of arms. * $a^*$ is the true best action. * A is the set of all arms. NOTE Instead of just jotting down the technical details of the algorithm I would like to take an intuitive approach of reaching the solution by starting off with a logical approaches and the mathematical evidences to back it up and then eventually reaching the algorithm ### Prerequisite mathematical knowledge : ##### [Markov inequality](https://en.wikipedia.org/wiki/Markov%27s_inequality) * The probability that X, a non negative random variable,is greater than "a", is less than or equal to the expectation of X divided by "a". Mathematically $$pr[X \geq a] \leq E[X]/a $$ $$E[X] = \sum_0^\infty x^*pr[X=x]$$ * In this formula, instead of x, for all values of X $\geq$ a we put in a. Hence the total sum is bound to be greater than or at the least equal to this new RHS. ##### [Chernoff Hoeffding bound](https://en.wikipedia.org/wiki/Hoeffding%27s_inequality) * This is used put a bound on our estimated expectation of a random variable, given the number of times we sample that variable from its distribution. 1. Let x<sub>1</sub>,x<sub>2</sub> ... x<sub>t</sub> be random variables with a common range within [0,1]. 2. E[ x<sub>t</sub> | x<sub>1</sub>,x<sub>2</sub>....x<sub>t-1</sub> ] = $\mu$ for all t 3. S<sub>n</sub> = (x<sub>1</sub> + x<sub>2</sub> + ... + x<sub>n</sub>)/n ie S<sub>n</sub> is the empirical mean of x after sampling it n-times. 4. Given these conditions the Chernoff Hoeffding bound says that : $$pr[S_n \geq \mu+\epsilon] \leq exp[-2\epsilon^2n] $$ $$pr[S_n \leq \mu-\epsilon] \leq exp[-2\epsilon^2n] $$ 5. How does it apply to our situation? We are trying to estimate the true expected payoff of each arm by sampling their rewards at different time steps.For a particular arm "a" * Reward is the random variable * q<sub>*</sub>(a) is $\mu$ * n is the number of times arm "a" has been pulled.(often confused with the total time-steps) * Q(a) is S<sub>n</sub>, because we are maintaining Q(a) by calculating the mean of all the previous sampled rewards of arm "a" after every time step. ### Methods ##### 1. Naive PAC algorithm: Now that we have the prerequisite tools, what would be the first step toward solving this problem ? We know that if our algorithm manages to return an arm "a", which is epsilon close to the best arm in value, we are safe. So lets think of providing an assurance that this will happen eventually, or, in slightly more relevant terms, lets try to bound the probability of us going wrong by $\delta$. Let a' be any non-optimal arm, i.e., $$ q_*(a') < q_*(a^*) - \epsilon $$ It is clear that we don't want to return such an arm. But our algorithm *could* (could is used Because its estimate should be higher than all the arms for it to be actually returned) return it if our estimate for this arm is higher than that of the real best arm. i.e., if, $$Q(a') > Q(a^*)$$ Obviously, we would want to bound the probability of this event happening. $$pr[Q(a') > Q(a^*)] \leq pr[Q(a^*)<q_*(a^*)-\epsilon/2] + pr[Q(a')>q_*(a')+\epsilon/2] $$ $$pr[Q(a') > Q(a^*)] \leq 2exp[(-\epsilon^2l)/2]$$ * The first equation tries to bound the probability of the event that our estimation of a non optimal arm (a') is greater than our estimation of the real best arm (a<sup>*</sup>) by the probability of another event which is *atleast as likely to happen*. In simpler terms, our estimation *could* go wrong if we either have under-estimated the best arm by more than $\epsilon$/2 or over-estimated the arm $a'$ by more than $\epsilon$ /2. This is what the RHS of the first equation denotes.Another point of view to encapsulate this is that if neither of two events on the RHS happen, then there is no chance that the event on the LHS will occur, because there is atleast gap of $\epsilon$ between the true values of $a'$ and $a^*$. * The second equation is obtained by applying the Chernoff Hoeffding bound.Here, *l* is the number of times action a' was pulled. It is in our hands to decide the value of *l* now. We know that the probability of error should be smaller than $\delta$.And hence for each action it should be lesser than $\delta$/k.To find the value of *l* we equate $$2exp[(-\epsilon^2l)/2] = \delta/k $$ $$l = (2/\epsilon^2)log(2k/\delta)$$ Now that we've obtained the number of times we should pull every arm(l) our naive algorithm is ready: 1. Sample every arm "a" (2/$\epsilon$<sup>2</sup>)log(2k/$\delta$) times 2. Let Q(a) be the average of all *l* rewards 3. Output $a^*$ which is argmax<sub>a</sub>(Q(a)) Another important thing about PAC algorithms is their sample efficiency.Since we sample every arm (2/$\epsilon$<sup>2</sup>)log(2k/$\delta$) times, the sample efficiency of this algorithm is O((k/$\epsilon$<sup>2</sup>)log(k/$\delta$). ##### 2.Median Elimination method : Instead of pulling every arm a fixed number of times and then deciding the best one,this algorithm pulls every arm for some number of time-steps and then eliminates half of the inferior arms and repeats the same thing again until it is left with only one arm. It should be clear that this will require log<sub>2</sub>(k)(because half arms are eliminated at each round) of such rounds to return an epsilon best arm. * *l* = the current round. * $\epsilon_l$ is the epsilon for *lth* round. * $\delta_l$ is the delta for the *lth* round. * $S_l$ is the set of all arms in the *lth* round. Let's take a look at the algorithm first and then understand the intuition behind it. ##### Median Elimination($\epsilon$,$\delta$): 1. Set $S_l$ = A ,l=1 2. $\delta_l$ = $\delta$/2 3. $\epsilon_l$ = $\epsilon$/4 4. repeat : * sample every arm $a \in A$, $\frac{2log(3/\delta_l)}{\epsilon_l^2}$ times * find the median of Q(a) and denote it by $M_l$. *let $$S_{l+1} = S_l \sim {a : Q_l(a) < M_l}$$ This means that we remove all the arms that are lower in value than the median(half of the arms). * Let, $$\epsilon_{l+1} = \frac{3\epsilon_l}{4}$$$$\delta_{l+1} = \frac{\delta_l}{2}$$$$l = l+1$$ until $|S_l|$ = 1 This might seem cumbersome, but it is just a clever modification of the naive algorithm. To provide an ($\epsilon$,$\delta$) guarantee we normally try to bound the probability of going wrong by $\delta$. But now that our algorithm works in rounds, we need to bound the probability of going wrong for every round.This was how the developers of this algorithm must have thought while trying out this "every round PAC" style. let E be the desirable event that after every round our losses in the best arm shouldn't be more than $\epsilon_l$, ie $$pr[E] = pr[max_{j\in S_l} q_*(j) \leq max_{i\in S_{l+1}} q_*(i) + \epsilon_l]$$ Event "E" might not occur if the subsequent two events take place 1. The algorithm grossly underestimate the value of the best arm at *lth* step.Let $E_1$ be this event. Let $$ E_1 = Q(a_l^*) < q_*(a_l^*) - \epsilon_l/2 $$ Where, $a_l^*$ = the real best arm at round *l*. We apply the Chernoff bound to the probability of this event and obtain: $$pr[E_1] \leq \delta_l/3 -(i)$$ 2. Given that the first event($E_1$) doesn't occur, still we could grossly over-estimate |S<sub>l</sub>|/2 bad arms to be empirically better than the real best arm at round *l*. Given that E<sub>1</sub> doesn't occur, $$E_2 = Q(j) \geq Q(a_l^*)| !E_1 $$ where, j is not an $\epsilon_l$ optimal arm.Hence $E_2$ is the event where we grossly over-estimate a non optimal action j,given $E_1$ doesn't occur.We again apply Chernoff bound to place an upper bound on its probability. $$pr[E_2] \leq pr[Q(j) \geq q_*(a_l^*) + \epsilon_l/2 | !E_1] \leq \delta_l/3$$ To fail, we need $\frac{S_l}{2}$ arms like non $\epsilon_l$ optimal arms(like j) to be empirically better than $a_l^*$ Lets #bad be the number of bad arms for which $E_2$ holds. Therefore, we have an upper bound on the expected number of #bad arms.(sum of the probablities of every arm going being a #bad arm($\sum_{a = 1}^{|S_l|} \delta_l/3$)) $$E[bad|!E_1] \leq |S_l|(\delta_l/3)$$ Now we use the Markov inequality to find probability that the number of #bad arm is atleast $|S_l|/2$ $$ pr[ bad \geq \frac{|S_l|}{2} |!E_1] \leq \frac{|S_l|(\delta/3)}{|S_1|/2} = 2\delta/3 -(ii)$$ Since (i) and (ii) are the probabilities of two unfavorable and independent events we can add them directly to obtain the upper bound of the failure at the *lth* round $$pr[E] = pr[max_{j\in S_l} q_*(j) \leq max_{i\in S_{l+1}} q_*(i) + \epsilon_l] \leq \delta_l$$ We have proved that the algorithm can give an ($\epsilon_l,\delta_l$) guarantee for every round,we just need to prove that 1. $\sum_{l = 1}^{log_2(k)} \epsilon_l \leq \epsilon$ 2. $\sum_{l = 1}^{log_2(k)} \delta_l \leq \delta$ Which can be easily shown as the series of coefficients of epsilon's and delta's converge to 1 when extended till infinity. Since they only reach upto $log_2(k)$ they are always less than one. Check out my Python implementation of Median Elimination methods [here](https://github.com/Raj19022000/RL-research/tree/master/Unit1-Multi-Armed-Bandits)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully