Why can't NormalMixture node accept fixed mean/precision parameters? #559
-
|
When using the NormalMixture node, the means m and precisions p must be sampled from distributions rather than specified as fixed values: # We have to initialize every element of m and p from a distribution
m[1] ~ NormalMeanPrecision(...) # etc...
p[1] ~ GammaShapeRate(...) # etc...
x ~ NormalMixture(switch=z, m=m, p=p)
# This doesn't work - why not?
m = [0.0, 5.0] # fixed means
p = [1.0, 1.0] # fixed precisions
x ~ NormalMixture(switch=z, m=m, p=p)I understand I can use very tight priors to approximate fixed values, but since the inference is still computing posteriors for the switch variables z, why is it necessary for m and p to be probability distributions rather than fixed constants? I'll give a bit of context with an example. Suppose I'm trying to estimate a 1D position |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
|
It should be possible imo, there is no particular reason rather than the rules are written such that they only accept distributions. But we should be able to extend it to accept fixed parameters. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @meditans! I am a bit familiar with the code, which helped. What I did was investigate the normal mixture node, which is implemented in ReactiveMP.jl here. (reactive message passing is the package that implements the nodes RxInfer uses) In that file, I noticed on lines 20 and 21 that the means and precisions are expected to be tuples, so I decided to try running inference where I give them as tuples. I hope that answers your question; if you have more, don't hesitate to ask! |
Beta Was this translation helpful? Give feedback.
I took a look and I think I can get your example to work. I define this model:
Then if I try to run inference by calling
I get "ERROR: The number of means and precisions in
NormalMixturemust be at least 2. Got1means and1precisions." If I change the brackets of m and p to round brackets, so that they are given as tuples:it works! We suspect the issue is that GraphPPL…