You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that binomial(n) gets linearly slower as n increases.
This makes no sense: binomial() should be constant-time, independent of n.
Minimal repro: Without @njit, this finishes in 1 second on my laptop, with @njit it never finishes and lines output incrementally slower.
importnumpyfromnumbaimportnjit@njit# with this on, `binomial(n)` get slower the bigger `n` getsdefmain():
forninrange(1000000):
ifn%1000==0:
print(n)
numpy.random.binomial(n*n//100, 0.2) # using n*n to show the effect even strongerif__name__=='__main__':
main()
numba 0.59.1 on NixOS.
The text was updated successfully, but these errors were encountered:
Thanks for the report, the above reproduces locally. I think the issue is that in NumPy the algorithm branches to use the BTPE algorithm under conditions where n * p is larger (there's a note about it in the Numba implementation):
Perhaps one option would be to switch to using numpy.random.Generator().binomial(...) for now (note that to do this you'd have to pass a Generator instance into the Numba compiled function though)?
Fixing this probably isn't too hard, it just requires fixing up the numpy.random.binomial implementation to more closely follow that in NumPy.
I found that
binomial(n)
gets linearly slower asn
increases.This makes no sense:
binomial()
should be constant-time, independent ofn
.Minimal repro: Without
@njit
, this finishes in 1 second on my laptop, with@njit
it never finishes and lines output incrementally slower.numba
0.59.1
on NixOS.The text was updated successfully, but these errors were encountered: