Inferencing about Objects #457
Replies: 1 comment 15 replies
-
A follow-up to the original post: I did some searching and came to the conclusion that what I'm trying to do in the last 2 lines of the model is to have y represent a mixture distribution of y1 and y2. Since I assume y1 = Normal(s1, .5) the documentation on the RxInfer page leads me to believe there are 2 ways to construct y: the Mixture and the NormalMixture distributions. Now I have the question whether it is possible to implement a model using the Mixture distribution that displays the same behavior as a model implemented using NormalMixture, and if so, which one should I prefer? For now I tried to run the following using RxInfer, Random, Plots, LaTeXStrings, Distributions
y_dataset = [.8, -1.8]
@model function mixture_model(y)
s1 ~ Normal(mean=-2, variance=1)
y1 ~ Normal(mean=s1, variance=.5)
s2 ~ Normal(mean=2, variance=1)
y2 ~ Normal(mean=s2, variance=.5)
o ~ Bernoulli(.5)
y .~Mixture(switch=o, inputs=[y1, y2])
end
results = infer(
model = mixture_model(),
data = (y = y_dataset,),
returnvars = (s1=KeepLast(), s2=KeepLast()),
addons = AddonLogScale(),
postprocess = UnpackMarginalPostprocess(),
) But it returns the following error.
The error clearly states what is wrong, but I'm unsure as how to interperate it: should I see this as a sign that my model is wrong? Or should I start tinkering with whatever is going on behind the screens of RxInfer? Any help would be much appreciated!! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
I have a setting where I want to inference information about multiple objects based on some observations (eventually online/streaming). To start easy, each object$i$ is associated with a sate $s_i$ , which for now represents the believe about a 1D position of object $i$ . In this simplified setting, an observation $y$ is a single position measurement of only one of the objects, which one is unknown. Consecutive measurements may contain information about different objects. So far I have managed to implement a numerical solution using Python for 2 objects, but this scales horribly with increasing number of objects and object complexity. I'm hoping RxInfer will provide a more elegant solution.
The problem is that I am not quite sure how my Python "solution" translates to a model which can be used for inference. My current implementation revolves about the following likelihood model (for 2 objects):
$p(y|s_1, s_2, o) = p(o=1)p(y|s_1) + p(o=2)p(y|s_2)$ $o$ is sort off a selection variable: $p(o=i)$ represents the chance that the measurement $y$ originates from object $i$ . Furthermore, $p(y|s_i)$ represents how the observation depends on the state of an object.
Where
I have tried to implement this model for RxInfer in the following way:
Apart from it failing to perform an inference cycle, I'm also convinced that this is not the way to implement the "object selection" as is done in the likelihood model above. However, I'm clueless as to what would be the correct way. If anyone has some suggestions that would be most welcome!!!
P.s.
I hope the explanation is clear. If not, please let me know :)
Beta Was this translation helpful? Give feedback.
All reactions