QuantEcon / meta

For issues and discussion covering more than one repository
0 stars 0 forks source link

[lectures] review `seed` is in place for any lecture using random numbers #37

Open MaxGhenis opened 5 years ago

MaxGhenis commented 5 years ago

Minor suggestion to set the numpy random seed in lectures that generate random numbers. This would ensure that users get the same results as those posted on lectures.quantecon.org when they run the notebooks themselves.

The np.random module is currently used in 56 scripts: https://github.com/QuantEcon/lecture-source-py/search?q=np.random&unscoped_q=np.random

natashawatkins commented 5 years ago

Hi @MaxGhenis, yep we have discussed this before. A couple of lectures do set seeds where results vary a lot. I'm not entirely convinced though that we should add them to all lectures - I think slight discrepancies in results. should emphasise to readers that there is a stochastic element. @jstac may have an opinion.

Harveyt47 commented 4 years ago

One source of significant difference in output is via a Markov Chain(for instance the solution the exercise 1). This can be fixed where the qe markov function has the variable random_state. Setting random_state=seed will make output consistant.

mmcky commented 4 years ago

@Harveyt47 I can't remember. Have you submitted a PR for this. I know you were looking into the seed issue.

Harveyt47 commented 4 years ago

I haven't for the markov chain one but I will. I was working on wealth dynamics as well and got an understanding of how seeds worked with numba. I wasn't completely sure if we were going to set seeds across all lectures

mmcky commented 1 year ago

It looks like wealth_dynamics doesn't have a seed set.

@jstac I recall at some stage we were debating if this complicated the code or not but it looks like most other lectures that are stochastic have set seeds. Perhaps @HumphreyYang could take a look through the lectures.

HumphreyYang commented 1 year ago

It looks like wealth_dynamics doesn't have a seed set.

@jstac I recall at some stage we were debating if this complicated the code or not but it looks like most other lectures that are stochastic have set seeds. Perhaps @HumphreyYang could take a look through the lectures.

Hi @mmcky,

I think for most of part of the lecture, having random samples is not a huge issue for consistency in results, but given the lecture is presented as a static page, setting a seed may benefit people who follow the lecture and implement our code line-by-line themselves. So, I think adding a seed will be a good idea.