MarkovChain.simulate API change; random_state option added#166
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 correctedThis 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.)
simulatemethod assimulate(ts_length, init=None, num_reps=None, random_state=None); see Update MarkovChain withreplicatemethod and Future Numba Improvements #146 (comment).initnow does not accept a distribution; see Update MarkovChain withreplicatemethod and Future Numba Improvements #146 (comment) and Update MarkovChain withreplicatemethod and Future Numba Improvements #146 (comment).random_stateoption is added toMarkovChain.simulate(not toMarkovChain.__init__).test_mc_sample_pathis added withrandom_statespecified.