brian-j-smith / Mamba.jl

Markov chain Monte Carlo (MCMC) for Bayesian analysis in julia
Other
253 stars 52 forks source link

Support for custom data type #156

Open erathorn opened 5 years ago

erathorn commented 5 years ago

Hi all, thank you for creating this awesome package. I am currently trying to set up a model which among other things samples tree structures. Unfortunately, adding tree structures to Mamba seems to be impossible. Of course, I can represent the tree structure in terms of an adjacency matrix, but the matrix grows to a point where it seems to be infeasible to store it as an ArrayStochasctic if it needs to be monitored, not mentioning the different kind of summarization which is necessary for tree structures. So my question is: Is there a way to add an interface for a custom data type to Mamba? So far all my attempts were abruptly stopped by ArgumentError("nodes are not all Dependent types") (model.jl line 10).

bdeonovic commented 5 years ago

For these kinds of situations I always find it easier to use what Brian calls the "stand alone functions" for the samplers. This is more of a manual way of running MCMC in mamba which allows you to circumvent some of the convenience functions. Each sampler in the doc has an example of using it in this "stand alone" way. See for example the NUTS sampler code:

https://mambajl.readthedocs.io/en/latest/samplers/nuts.html#stand-alone-function

I hope that helps!