-
Notifications
You must be signed in to change notification settings - Fork 432
fix the rand!() function for the Beta distribution. #1281
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
Conversation
For the Beta distribution, the compiler cannot infer the type of the output, so this causes unnecessary memory allocation. Defining the sampler at the argument level of the function solve the problem.
Codecov Report
@@ Coverage Diff @@
## master #1281 +/- ##
==========================================
- Coverage 81.34% 81.28% -0.07%
==========================================
Files 117 115 -2
Lines 6563 6529 -34
==========================================
- Hits 5339 5307 -32
+ Misses 1224 1222 -2
Continue to review full report at Codecov.
|
|
I'm not sure why we should expose this as an argument. Could you provide more information about the issue that you are fixing here? |
|
Consider the following example: `using Random, Distributions 0.000091 seconds (1.49 k allocations: 23.328 KiB)` The 23.328 KiB allocations is undesirable. |
|
I see. I think it's better to change the loop to an in-place map like map!(t -> rand(rng, smp), A, eachindex(A))That gives a function barrier as well. |
|
Agree, however, I guess (generally) optimising |
|
It seems that using loop require 2/3 of allocation compared to |
|
Can't we just introduce a proper function barrier instead of the somewhat weird keyword argument that one is not supposed to use anyway? |
|
I opened a PR that introduces a function barrier without adding any keyword argument to |
|
Superseded by #1350 |
For the Beta distribution, the compiler cannot infer the type of the output, so this causes unnecessary memory allocation. Defining the sampler at the argument level of the function solve the problem.