-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use Sampler
interface?
#73
Comments
I don't know who originally came up with the I played around with the interface some more, and while I don't know whether it's proper, the following also works (at least for naive
But I suspect this is not proper... |
Looking back at where the various generators are defined, I really don't think the version above is good/proper. That at least has some more comments about how samplers work, maybe they're of help as well? |
Could be nice. I remember running into of dispatch ambiguities with the sampler interface extensions in the past through, we'll probably need to do this carefully. |
A way to define
Actually, typically when we are calling (i'm happy to try to answer questions here, but tag me to get my attention) |
In a recent Zulip discussion (https://julialang.zulipchat.com/#narrow/stream/137791-general/topic/Static.20code.20blocks/near/289768224), @Seelengrab reminded me of the
Random.Sampler
interface, with this example:This makes it so you can call e.g.
Our current implementation ignore this interface, instead working entirely in terms of dispatching to
rand
. Ourrand
takes three arguments, with these defaults:Here the type argument in the second position is passed to the "inner"
rand
call. For example,I think it's very useful to keep this kind of flexibility, but it could help to also have thing set up in a way to take advantage of the Sampler interface. It's very new to me and doesn't seem to be well-documented. But maybe we can go from examples or ask for help if we get stuck.
One thing to consider is that we can easily build measures over spaces more complex than a simple scalar or array. To minimize allocations in cases like this, I've previously explored having every
rand
have two steps: an allocation, followed by a call torand!
to fill in the values. It's not clear to me if this is the "right" way to do things. As usual in this ecosystem, we need to think a lot about composability and its impact on performance.The text was updated successfully, but these errors were encountered: