-
-
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
MarkovChain.simulate API change; random_state option added #166
Conversation
Regarding testing methods/functions with randomness (i.e., If
|
In case >>> # If init is an array, num_reps is ignored
... mc.simulate(10, init=[0, 1], num_reps=3)
array([[0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) But would it be better to generate [[0, ...],
[1, ...],
[0, ...],
[1, ...],
[0, ...],
[1, ...]] |
@oyamad I see this PR has some merge conflicts thanks to the change in # -Check if Numba is Available- #
<<<<<<< HEAD
from ..util import searchsorted, check_random_state, numba_installed, jit
=======
from ..external import numba_installed, jit
from ..util import searchsorted, check_random_state
>>>>>>> Import statements corrected
This seems like sensible behaviour - rather than ignoring |
Only for shape
based on discussion #146 (comment)
test_simulate_lln replaced by test_mc_sample_path_lln
I did a rebase and made a forced push. (I wonder if this is a good conduct...) |
Great - thanks @oyamad. I will wait for the update in behaviour and then we can merge this PR. |
Now return len(init)*num_reps sample paths
Now >>> mc.simulate(10, init=[0, 1], num_reps=3, random_state=1234)
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]]) |
Thanks @oyamad are you happy for this to be merged?
I think these are good additions to the tests suite. |
@mmcky Yes, thanks! |
MarkovChain.simulate API change; random_state option added
This follows the discussions in #146.
(I hope I did "rebase" in the right way.)
simulate
method assimulate(ts_length, init=None, num_reps=None, random_state=None)
; see Update MarkovChain withreplicate
method and Future Numba Improvements #146 (comment).init
now does not accept a distribution; see Update MarkovChain withreplicate
method and Future Numba Improvements #146 (comment) and Update MarkovChain withreplicate
method and Future Numba Improvements #146 (comment).random_state
option is added toMarkovChain.simulate
(not toMarkovChain.__init__
).test_mc_sample_path
is added withrandom_state
specified.