-
Notifications
You must be signed in to change notification settings - Fork 222
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
Simple syntax for querying the model and posterior sample #989
Comments
I can also provide an |
I suggest we also allow |
I like it, I think it'd be a good tool to have. I have no helpful comments, so I guess you're welcome? |
I am working on it. |
|
I agree, it feels a bit strange to me. I think it would be more natural to write @logprob a = 1.0, b = 2.0 | model = demo for the prior probabilities @logprob a = 1.0, b = 2.0, x = x, y = y | model = demo for the joint probability |
@xukai92 the log joint probability case will replace the data inside Actually, for all of them I can just make a function under the hood that can be called instead of the macro. So I have a few questions for you all:
|
I would actually prefer to have both. People who do a lot of automated model stuff would prefer a function API, whereas all the folks who are messing around with the REPL prefer the macro API. Might be that one ends up being better than the other, so we could deprecate one if it is just less useful. |
Sounds good. |
Re 1: I agree with Cameron that we do need both. |
Will this allow this also allow to return the point logp of the each data point given a parameter set? |
Yes |
That's pretty cool. Is this available once the referenced PR is accepted? |
Yup! |
I am slightly confused by the above feature. It seems like this should be a filter-style function in the |
Hypothesis testing, for one. If you wanted to have some measure of confidence about whether a parameter is negative and you wanted a quick check: @logprob a >= 0 | model=model, chain=chain I think it's a little nicer to work with than a |
Indeed IMO that feature seems more like one of the other convenient functionalities provided by MCMCChains. It is also not clear to me why specifying The nice thing about using a function instead of a macro would be that one could just dispatch on
To me logprob(chain) do sample
sample.a >= 0
end doesn't feel too bad and actually more powerful and flexible than a macro. |
I like that! I think we could probably stick this on the MCMCChains side. |
I agree that this doesn't belong here. I actually left it out from #997 . |
You're referring only to the filtering functionality, I guess? As far as I can see, #997 contains the chain-based feature
|
@devmotion yes that feature is actually important, @trappmartin and @sethaxen have uses for it. Imo, I see this belongs to
|
To me that sounds like the syntax should be just
Sure, but does this imply that this functionality can't be provided in, e.g., MCMCChains? |
Hmm using the model in |
Yes we need access to |
So here is a nice middle ground, if |
Hmm nevermind, that won't be necessary if |
Even if it is saved by default, I will leave the backup there. |
No reason that I can think. You could probably just set the keyword |
Cool, thanks! |
Closed via #997. |
In this issue, I propose the creation of a new macro
@logprob
to query Turing models as well as the sampled posterior. Let's take the following model as an example using the syntax of #965:I propose the following syntax:
@logprob a = 1.0, b = 2.0 | model = model
-> returns log the prior@logprob a = 1.0, b = 2.0, x = rand(100), y = rand(100) | model = model
-> returns log the joint probability@logprob 0.2 <= a <= 0.3, 1.0 <= b <= 1.1 | model = model, chain = chain
-> returns log the ratio of the number of samples inchain
with0.2 <= a <= 0.3, 1.0 <= b <= 1.1
. For discrete distributions, we can also usea = 2
ora == 2
for example. Passingmodel
here can be optional.@logprob x = rand(10), y = rand(10) | model = model, chain = chain
returns the log likelihood ofx = rand(10), y = rand(10)
for each sample inchain
@logprob x = rand(10), y = rand(10) | model = model, a = 1.0, b = 2.0
returns the log likelihood ofx = rand(10), y = rand(10)
usinga = 1.0, b = 2.0
.Let me know if you have comments on the syntax or if I missed any use case.
The text was updated successfully, but these errors were encountered: