-
|
I am attempting to combine two independent random variables, conceptually i want to stack two random variables to form a new one : using RxInfer
@model function stacking_example(x)
z1 ~ Normal(mean= 1, var=10)
z2 ~ Normal(mean=10, var=1)
z := vcat(z1, z2) # (obviously here it could be just substituted by a Mv distribution)
x ~ MvNormalMeanPrecision(z,[1 0; 0 1])
end
result = infer(
model = stacking_example(),
data = (x = [-1, -1.4],),
meta = @meta(begin
vcat() -> Linearization()end)
)obtained error message: my environment: i added callbacks and some own debugging to better track the problem. it seems to me the forward pass through the DeltaNode successfully constructs a MvNormalMeanCovariance(μ: [1.0, 10.0], Σ: [10.0 0.0; 0.0 1.0]. combined with backward pass, z is also successfully updated. the problem happens then after the marginal update of z: -> system breaks here |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
I cannot reproduce, works fine on my end julia> using RxInfer
julia> @model function stacking_example(x)
z1 ~ Normal(mean= 1, var=10)
z2 ~ Normal(mean=10, var=1)
z := vcat(z1, z2) # (obviously here it could be just substituted by a Mv distribution)
x ~ MvNormalMeanPrecision(z,[1 0; 0 1])
end
julia> meta = @meta(begin
vcat() -> Linearization()end)
Meta:
vcat() -> Linearization()
julia> result = infer(
model = stacking_example(),
data = (x = [-1, -1.4],),
meta = meta
)
Inference results:
Posteriors | available for (z1, z2, z)I'm not sure though if the |
Beta Was this translation helpful? Give feedback.
-
|
Is something similar possible for a manual construction of the precision matrix instead of sampling from a Wishart distribution? using RxInfer, LinearAlgebra
@model function stacking_example(x)
p1 ~ Gamma(shape=1, scale=1)
p2 ~ Gamma(shape=1, scale=1)
p := diagm([p1, p2]) # throws: Error trying to display an error.
# p ~ Wishart(3, diagm([1,1])) # works
x ~ MvNormalMeanPrecision([0, 0], p)
end
result = infer(
model = stacking_example(),
data = (x = [2, 2],),
meta = @meta(begin
diagm() -> Unscented() end)
)to exclude its the row1 := hcat(p1, 0.0)
row2 := hcat(0.0, p2)
p := vcat(row1, row2)I ran some debugging (using callbacks and also local versions of so it seems to happen after sending backward message from MvNormalMeanPrecision-Node to precision variable node. Side note: to make the logging actually work, i needed to adapt the @rule MvNormalMeanPrecision(:Λ, Marginalisation) (q_out::Any, q_μ::Any). Adding a small correction term to ensure we send a Wishart with a valid (inverse)Scalematrix (e.g. when both are pointmasses and have the same values, invS gets a singular, 0-matrix. and the resulting Wishart is undefined -> i might better open a different issue for that?! |
Beta Was this translation helpful? Give feedback.
I cannot reproduce, works fine on my end