Replies: 1 comment 3 replies
-
Hi @lstagner! (UPD from @Nimrais ) There are multiple ways to handle this problem. I'll provide how I'd approach it without overthinking, though others might suggest more interesting solutions. To get things going, you could do the following. I'll be using the Projections method due to the non-conjugacy: using RxInfer
using ExponentialFamilyProjection
@model function constrained_dice(m, dims)
x ~ Dirichlet(ones(dims))
c = collect(1:dims)
for i in eachindex(m)
m[i] ~ NormalMeanVariance(dot(x, c), tiny)
end
end
dataset = fill(4.5, 100);
@constraints function dice_constraints(dims)
q(x) :: ProjectedTo(Dirichlet, dims...)
end
constraints = dice_constraints((6,))
result = infer(
model = constrained_dice(dims=6),
data = (m = dataset, ),
constraints = constraints,
iterations = 5
)
@show result.posteriors[:x][end] I haven't checked whether results makes sense, so I am leaving this to you. Another (perhaps faster) alternative would be this tutorial For undefined rule, I suggest this doc! @Nimrais, for some reason I couldn't turn on free energy computations. Can you have a look? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was playing around with RxInfer and I wanted to see if I can use it to create constrained priors. There is an example in Sivia's Data Analysis: A Bayesian Tutorial.
The solution to this problem is to do a constrained optimization of the entropy. I figured that since RxInfer does free energy minimization which is related to entropy it should be able to figure it out. I couldn't find anything in the documentation that so I figured I would try to just run a model where the measurements are the mean and just repeat the "measurement" of 4.5.
Unfortunately, this doesnt work for a number of reasons.
Dirichlet(ones(6))
fixes it..~
fixes that.no method matching +(::GraphPPL.NodeLabel, ::GraphPPL.NodeLabel)
OK just manually do the sum.x[1] + 2*x[2] + 3*x[3] + 4*x[4] + 5*x[5] + 6*x[6]
MethodError: no method matching factornode(::ReactiveMP.UndefinedNodeFunctionalForm, ::Type{PointMass}, ::Vector{Tuple{Symbol, AbstractVariable}}, ::Tuple{Vector{Int64}, Vector{Int64}})
OK. just replace that with a normal with a small variance.Here is the "corrected" model
and this throws out a rule error
RuleMethodError: no method matching rule for the given arguments
.At this point I am stuck and curious if this is the right approach to create constrained priors.
Beta Was this translation helpful? Give feedback.
All reactions