-
-
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
BUGs in random_choice #393
Comments
@oyamad I need to draw one variate from a fixed discrete distribution until a stopping condition is satisfied, in a loop. It needs to be fast. I don't know the size of the sequence ex ante. |
@jstac I see. Would it be possible to set a seed in your own function, removing |
@oyamad Yes, that's certainly possible. Regarding the numba version, thanks for picking that up. Version 0.36.2 has many problems. So, the proposal is
|
@oyamad This is beautiful. Thank you. I learned a lot from reading the code. I fully support this. Would you mind to make a PR? |
I tried the recently merged
random_choice
#391 and found the following:This doesn't work with Numba v.0.36 with the following error:
It works with Numba v.0.37, so this should be a bug in Numba v.0.36. The problem for us is that the latest Anaconda contains Numba v.0.36.2.
Setting a seed with
np.random.seed
within a library (hidden from the user) is problematic: it seems to affect Numba's global random state.Suppose you have the following jit function:
Call it after calling
random_choice
with the same seed (with Numba v.0.37):Then it always returns the same sequence:
@jstac What is your use case where you need a jitted version of this functionality? What's wrong with generating random numbers outside your jit function and then using
np.searchsorted
(orqe.searchsorted
) inside the jit function?The text was updated successfully, but these errors were encountered: