-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Compound/Gibbs step and discrete suppot #306
Conversation
Here is the trivial example from sampling from pm.Categorical: @pm.model
def categorical():
var1 = yield pm.Categorical("var1", probs=[0.2, 0.4, 0.4])
var1 = yield pm.Categorical("var2", probs=[0.1, 0.3, 0.2, 0.2, 0.2])
var1 = yield pm.Categorical("var3", probs=[0.1, 0.1, 0.1, 0.1, 0.1, 0.5])
trace = pm.sample(categorical(), sampler_type="compound")
# after the review default attribute should be compound and if there is no
# discrete variable in the model, we choose nuts as the sampler I've included the notebook with discrete distributions: discrete_distributions_sampling.ipynb |
Som results with different proposal generations for @pm.model
def model():
var1 = yield pm.Poisson("var1", 4) # gaussian with round dist proposal
var1 = yield pm.Poisson("var2", 4) # poisson dist proposal
var2 = yield pm.Poisson("var3", 4) # continous space
trace = pm.sample(model(),
sampler_type="compound",
sampler_methods=[
("var1", RandomWalkM, {"new_state_fn": gaussian_round_fn}),
("var2", RandomWalkM, {"new_state_fn": functools.partial(poisson_fn, scale=4)}), # not sure if this is the right way to define proposal
],
trace_discrete=["var1", "var2"])
|
@junpenglao Can you also suggest something better with the |
@rrkarim is this ready for review? if so could you resolve the conflicts? |
This is awesome contribution! Thanks and great job :-) |
one_step
in compound samplersampler_type
the default for the model with discrete and continuous distributions.