Skip to content

Commit a65f940

Browse files
committed
make PRNG key explicit in plot_epochs calls for consistent results
1 parent d6034fe commit a65f940

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lectures/mccall_q.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,8 @@ valfunc_VFI
680680
```
681681
682682
```{code-cell} ipython3
683-
def plot_epochs(epochs_to_plot, quit_allowed=1, key=None):
683+
def plot_epochs(epochs_to_plot, quit_allowed=1, key=key):
684684
"Plot value function implied by outcomes of an increasing number of epochs."
685-
if key is None:
686-
key = jax.random.PRNGKey(42) # Default key if none provided
687685
688686
qlmc_new = create_qlearning_mccall(w=w_new, q=q_new, quit_allowed=quit_allowed)
689687
qtable = jnp.zeros((len(w_new),2))
@@ -715,7 +713,7 @@ def plot_epochs(epochs_to_plot, quit_allowed=1, key=None):
715713
```
716714
717715
```{code-cell} ipython3
718-
plot_epochs(epochs_to_plot=[100, 1000, 10000, 100000, 200000])
716+
plot_epochs(epochs_to_plot=[100, 1000, 10000, 100000, 200000], key=key)
719717
```
720718
721719
The above graphs indicates that
@@ -761,7 +759,7 @@ But if we increase the number of epochs/episodes, we can observe that the error
761759
We illustrate these possibilities with the following code and graph.
762760
763761
```{code-cell} ipython3
764-
plot_epochs(epochs_to_plot=[100, 1000, 10000, 100000, 200000], quit_allowed=0)
762+
plot_epochs(epochs_to_plot=[100, 1000, 10000, 100000, 200000], quit_allowed=0, key=key)
765763
```
766764
767765
## Possible extensions

0 commit comments

Comments
 (0)