Closed nswa17 closed 6 years ago
@nswa17 I have a few comments on your PR. Can we talk tomorrow during the office hours?
One question: What is the "scope" of srand(12345)
? Is it effective for the whole session on the notebook?
Yep, srand
sets the seed on Julia's global RNG.
If you want to isolate its effects you can construct your own instance of a RNG (e.g MersenneTwister(0)
) and then call srand
on that.
julia> methods(srand)
# 9 methods for generic function "srand":
srand() in Base.Random at random.jl:244
srand(r::MersenneTwister) in Base.Random at random.jl:232
srand(r::MersenneTwister, seed::Array{UInt32,1}) in Base.Random at random.jl:145
srand(r::MersenneTwister, n::Integer) in Base.Random at random.jl:233
srand(r::MersenneTwister, filename::AbstractString) in Base.Random at random.jl:234
srand(r::MersenneTwister, filename::AbstractString, n::Integer) in Base.Random at random.jl:234
srand(seed::Union{Array{UInt32,1}, Integer}) in Base.Random at random.jl:249
srand(filename::AbstractString) in Base.Random at random.jl:254
srand(filename::AbstractString, n::Integer) in Base.Random at random.jl:254
@sglyon Thanks.
What's the "best practice" in Julia for reproducibility with code involving randomness, if any? In QE.py, some routines encourage to use a random_state
option; e.g., see this notebook below cell [21]
(also QuantEcon/QuantEcon.py#153).
We once discussed this in a different issue QuantEcon/QuantEcon.jl#63. Do we want to have an rng
option in functions with randomness in QE.jl?
Sorry for the delay in responding here.
I don’t think there is a best practice yet...
As you say, we could have all the routines take an optional argument rng
of type RNG
(An abstract type that all random number generators subtype).
The workaround right now is that users set the seed on the global RNG before each call to one of quantecon’s routines with randomness. I’m not sure how many people would take advantage of the rng
option on these functions. If there wouldn’t be many, mabye it isn’t worth the hassle?
If you can’t tell, I don’t yet have a concrete opinion on this issue yet.
@sglyon Thanks.
For this particular case of this notebook, I think we shouldn't make any comment on reproducibility. (The main purpose of the corresponding comment in the Python version is to explain the random_state
option.)
I have a question on the header of notebooks. Are there any general rules of author in Quantecon.notebooks? Especially for the typical case of translation from an existing notebook?
prettyprint
looks a good idea.pi
should be avoided for a stationary distribution (pi
is reserved for as a math constant in Julia). May try psi
as in the lecture.I'm sorry to forget to use defined prettyprint
function in cell Ln[55].
Also I changed the name of variable pi
in cells into psi
.
There still remain several pi
s (and also in math expressions in LaTeX). Search for them.
I thought the pi
s in the math expressions are more familiar than psi
.
Sorry for that. I fixed it.
I should have told you to search for "π", too.
Fixed it. I hope this is OK. Sorry to be late.
@oyamad It's a good question. There's no policy. Perhaps we should have one. The general rule going forwards is that good behavior is enforced by the market (upvotes and downvotes). But sometimes we observe market failure...
For translations, an attribution of the original author(s) plus "edited by" the new author seems suitable.
I had a look and this is fine as is.
Add julia translation of markov_chain_ex01_py.ipynb.