Skip to content

Contigency factor node #454

Answered by wouterwln
mateusjoffily asked this question in Q&A
Feb 21, 2025 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

I kind of fail to see where the actual data you have about either x or y enters the model, but the following code puts a prior on y that models a joint dependency between the two (they are always equal):

@model function transition_demo(y_mat, α)
    x ~ Dirichlet(α)
    y[1] ~ Categorical(x)
    y[2] ~ Categorical(x)
    y[1] ~ DiscreteTransition(y[2], y_mat)
end

init = @initialization begin
    q(x) = Dirichlet([1.0, 1.0])
end

constraints = @constraints begin
    q(x, y) = q(x)q(y)
end

result = infer(model=transition_demo(α=[1, 1]), data=(y_mat=[1.0 0.0; 0.0 1.0],), iterations=10, initialization=init, constraints=constraints)

Adding an additional prior on y[2] allows you to fully mod…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@mateusjoffily
Comment options

@wouterwln
Comment options

@mateusjoffily
Comment options

@wouterwln
Comment options

Answer selected by mateusjoffily
@mateusjoffily
Comment options

@wouterwln
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants