-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update MarkovChain with replicate
method and Future Numba Improvements
#146
Comments
I have pushed 95627f2 for discussion on this matter.
|
@oyamad : I'd like to have a detailed look at the code but I need a bit of time for this as I am completely under the water right now. |
I updated the
|
@oyamad : sorry for the long silence. I have read the whole module and overall, I like it. I have only very minor points:
|
:s/involutive/idempotent/g |
@albop Thank you for your comments!
Could you elaborate a bit more on the last two points? |
On point 2/ , I would tend to expect that mc.simulate(, random_state=1234) would not affect the stateful random generator and that simulate() or simulate(random_state=None) would take the seed from the current state. But in the latter case case, I am not sure whether we should commit to any particular behaviour so I don't have strong feelings there. |
On point 3/ I confess that I don't know in which case you may want to use a distribution for init... But since the feature was there, I guessed there had been a reason for it at some point and that it was not expensive to keep. Maybe there are some usecases in the lectures ? @jstac ? |
@albop And in your 5th point, are you saying that we should implement The reason why I coded |
Yes, exactly, that's what I meant for points 4 and 5. The bottom-line is that I am quite happy with the object version as it is. Potential reasons to implement a non-object version would be: Although they are easy to implement, reasons 1, 2, and 3 seem rather weak. The reason I was proposing 3, was that maybe we could the API right before adding the numba version later. So, let me apologize for the circumvolutions, I now think we should just keep the object as it is and deprecate/delete |
We also need to care about the consistency with the Julia version. Do you guys have any thoughts on this matter? > @spencerlyon2 @ZacCranko |
I do want to revamp the interface on the Julia side. My plan was to wait until this (and QuantEcon/QuantEcon.jl#32) settles and then match it if it seems appropriate there. I do have one request: I think that we should only export functions as methods on the |
@oyamad apologies just read this thread now.
I would expect if a user wanted a reproducible state that it would be specified rather than set permanently as part of the object. So I agree with your point above that it would return |
The new Finally it goes like: >>> from quantecon.markov import MarkovChain
>>> mc = MarkovChain([[0.4, 0.6], [0.2, 0.8]])
>>> seed = 1234
>>> mc.simulate(10, random_state=seed)
array([1, 1, 1, 1, 1, 1, 0, 0, 1, 0])
>>> mc.simulate(10, init=0, random_state=seed)
array([0, 0, 1, 1, 1, 1, 1, 1, 1, 1])
>>> mc.simulate(10, init=[0, 1], random_state=seed)
array([[0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0]])
>>> mc.simulate(10, num_reps=3, random_state=seed)
array([[1, 1, 1, 1, 1, 0, 0, 1, 0, 0],
[1, 0, 1, 1, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 1]])
>>> mc.simulate(10, init=0, num_reps=3, random_state=seed)
array([[0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0, 0, 1, 1, 1]])
>>> mc.simulate(10, init=[0, 1], num_reps=3, random_state=seed)
array([[0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 0, 0, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 0, 1, 1],
[0, 0, 1, 1, 1, 0, 0, 0, 1, 1],
[1, 1, 0, 1, 1, 1, 0, 1, 1, 0]]) |
From @albop
From @jstac
From @oyamad
The text was updated successfully, but these errors were encountered: