Skip to content

Commit f15a100

Browse files
committed
add discount factor when compute G
1 parent c6b7d3f commit f15a100

File tree

4 files changed

+547
-39
lines changed

4 files changed

+547
-39
lines changed

MC/MC Control with Epsilon-Greedy Policies Solution.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
" first_occurence_idx = next(i for i,x in enumerate(episode)\n",
134134
" if x[0] == state and x[1] == action)\n",
135135
" # Sum up all rewards since the first occurance\n",
136-
" G = sum([x[2] for x in episode[first_occurence_idx:]])\n",
136+
" G = sum([x[2]*(discount_factor**i) for i,x in enumerate(episode[first_occurence_idx:])])\n",
137137
" # Calculate average return for this state over all sampled episodes\n",
138138
" returns_sum[sa_pair] += G\n",
139139
" returns_count[sa_pair] += 1.0\n",
@@ -213,21 +213,21 @@
213213
],
214214
"metadata": {
215215
"kernelspec": {
216-
"display_name": "Python 3",
216+
"display_name": "Python 2",
217217
"language": "python",
218-
"name": "python3"
218+
"name": "python2"
219219
},
220220
"language_info": {
221221
"codemirror_mode": {
222222
"name": "ipython",
223-
"version": 3
223+
"version": 2
224224
},
225225
"file_extension": ".py",
226226
"mimetype": "text/x-python",
227227
"name": "python",
228228
"nbconvert_exporter": "python",
229-
"pygments_lexer": "ipython3",
230-
"version": "3.5.1"
229+
"pygments_lexer": "ipython2",
230+
"version": "2.7.11"
231231
}
232232
},
233233
"nbformat": 4,

MC/MC Control with Epsilon-Greedy Policies.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,21 @@
148148
],
149149
"metadata": {
150150
"kernelspec": {
151-
"display_name": "Python 3",
151+
"display_name": "Python 2",
152152
"language": "python",
153-
"name": "python3"
153+
"name": "python2"
154154
},
155155
"language_info": {
156156
"codemirror_mode": {
157157
"name": "ipython",
158-
"version": 3
158+
"version": 2
159159
},
160160
"file_extension": ".py",
161161
"mimetype": "text/x-python",
162162
"name": "python",
163163
"nbconvert_exporter": "python",
164-
"pygments_lexer": "ipython3",
165-
"version": "3.5.1"
164+
"pygments_lexer": "ipython2",
165+
"version": "2.7.11"
166166
}
167167
},
168168
"nbformat": 4,

MC/MC Prediction Solution.ipynb

Lines changed: 531 additions & 23 deletions
Large diffs are not rendered by default.

MC/MC Prediction.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,21 @@
118118
],
119119
"metadata": {
120120
"kernelspec": {
121-
"display_name": "Python 3",
121+
"display_name": "Python 2",
122122
"language": "python",
123-
"name": "python3"
123+
"name": "python2"
124124
},
125125
"language_info": {
126126
"codemirror_mode": {
127127
"name": "ipython",
128-
"version": 3
128+
"version": 2
129129
},
130130
"file_extension": ".py",
131131
"mimetype": "text/x-python",
132132
"name": "python",
133133
"nbconvert_exporter": "python",
134-
"pygments_lexer": "ipython3",
135-
"version": "3.5.1"
134+
"pygments_lexer": "ipython2",
135+
"version": "2.7.11"
136136
}
137137
},
138138
"nbformat": 4,

0 commit comments

Comments
 (0)