Comments (4)
The book mentioned that
there is a whole family of optimal policies, all corresponding to ties
I just wonder how you manage to make the policy figure exactly same as the book. It will be much appreciated if you could briefly talk about how you select actions if there is a tie?
from reinforcement-learning-an-introduction.
Under the Figure 4.3 it states: "In particular, for capital of 50 it bets it all on one flip, but for capital of 51 it does not." But this is misleading, since it is perfectly fine, i.e. optimal to bet 49 while in state 51. And:
"Why does the optimal policy for the gambler’s problem have such a curious form?"
there is a whole family of optimal policies, all corresponding to ties
you are right. I overlooked this remark and focussed on the caption of the figure and the remark in your code. Your code doesn't reproduce the policy plotted in the book, but you still obtain a different optimal policy.
Regarding implementation:
In the value iteration, nothing changes. the value iteration simply computes the value (a real number) for each state 0,1,...,100.
However, the arg max when establishing the greedy policy is often not unique. That means, if you notice that the maximum occurs for multiple actions, all these actions can be assigned a non-zero probability in a greedy policy.
In my implementation, the class GreedyPolicy
collects precisely all of these possible actions. Also, notice the class FairArgMax
.
Below, are the greedy actions for each state. (I hope that it's correct...)
0 -> {0}
1 -> {1}
2 -> {2}
3 -> {3}
4 -> {4}
5 -> {5}
6 -> {6}
7 -> {7}
8 -> {8}
9 -> {9}
10 -> {10}
11 -> {11}
12 -> {12}
13 -> {12, 13}
14 -> {11, 14}
15 -> {10, 15}
16 -> {9, 16}
17 -> {8, 17}
18 -> {7, 18}
19 -> {6, 19}
20 -> {5, 20}
21 -> {4, 21}
22 -> {3, 22}
23 -> {2, 23}
24 -> {1, 24}
25 -> {25}
26 -> {1, 24, 26}
27 -> {2, 23, 27}
28 -> {3, 22, 28}
29 -> {4, 21, 29}
30 -> {5, 20, 30}
31 -> {6, 19, 31}
32 -> {7, 18, 32}
33 -> {8, 17, 33}
34 -> {9, 16, 34}
35 -> {10, 15, 35}
36 -> {11, 14, 36}
37 -> {12, 13, 37}
38 -> {12, 38}
39 -> {11, 39}
40 -> {10, 40}
41 -> {9, 41}
42 -> {8, 42}
43 -> {7, 43}
44 -> {6, 44}
45 -> {5, 45}
46 -> {4, 46}
47 -> {3, 47}
48 -> {2, 48}
49 -> {1, 49}
50 -> {50}
51 -> {1, 49}
52 -> {2, 48}
53 -> {3, 47}
54 -> {4, 46}
55 -> {5, 45}
56 -> {6, 44}
57 -> {7, 43}
58 -> {8, 42}
59 -> {9, 41}
60 -> {10, 40}
61 -> {11, 39}
62 -> {12, 38}
63 -> {12, 13, 37}
64 -> {11, 14, 36}
65 -> {10, 15, 35}
66 -> {9, 16, 34}
67 -> {8, 17, 33}
68 -> {7, 18, 32}
69 -> {6, 19, 31}
70 -> {5, 20, 30}
71 -> {4, 21, 29}
72 -> {3, 22, 28}
73 -> {2, 23, 27}
74 -> {1, 24, 26}
75 -> {25}
76 -> {1, 24}
77 -> {2, 23}
78 -> {3, 22}
79 -> {4, 21}
80 -> {5, 20}
81 -> {6, 19}
82 -> {7, 18}
83 -> {8, 17}
84 -> {9, 16}
85 -> {10, 15}
86 -> {11, 14}
87 -> {12, 13}
88 -> {12}
89 -> {11}
90 -> {10}
91 -> {9}
92 -> {8}
93 -> {7}
94 -> {6}
95 -> {5}
96 -> {4}
97 -> {3}
98 -> {2}
99 -> {1}
100 -> {0}
from reinforcement-learning-an-introduction.
Oh got it, you just plot all the actions if there is a tie rather than just randomly select one. It makes the figure more good-looking. Thanks for your reply!
from reinforcement-learning-an-introduction.
I thank you for your awesome code and repository!
from reinforcement-learning-an-introduction.
Related Issues (20)
- Unable to get the same results while formulating differently HOT 1
- A simpler draw function HOT 2
- nit: chapter 6 references
- something wrong in matplotlib HOT 2
- Generalization to abstract classes for Environment/Agents? HOT 2
- tictactoe compete() plays 1000 almost identical games HOT 1
- typo
- wrong figure number for chapter 11
- ten_armed_testbed.py中的figure2_3为何不用“sample_averages”
- problem about chapter04/car_rental.py HOT 1
- example to use it on human genetic data?
- Problem of excercise 2.5
- The plicy of chapter1 HOT 1
- Wrong Bellman equation for Jack's car rental problem? HOT 1
- Unclear point for the code in Blackjack example HOT 1
- l
- ch06 random_walk td method HOT 1
- chapter4 gamblers_problem, showing multiple best actions
- Chapter 2: Couldn't find the file '../images/figure_2_1.png'
- Citing this repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reinforcement-learning-an-introduction.