Replies: 3 comments
-
Hi, that's an interesting question. I've written a model where I don't have Can you extend this for your use case? In my results I have a posteriors over using Distributions, RxInfer
using StableRNGs
function generate_data(a, b, v, nr_samples; rng=StableRNG(1234))
x = float.(collect(1:nr_samples))
y = a .* x .+ b .+ randn(rng, nr_samples) .* sqrt(v)
return x, y
end;
@model function linear_regression(y)
local x
a ~ Normal(mean = 0.0, variance = 1.0)
b ~ Normal(mean = 0.0, variance = 100.0)
γ ~ GammaShapeRate(1, 1000)
for i in 1:length(y)
x[i] ~ Normal(mean = 0.0, variance = 1.0)
_y[i] ~ softdot(a, x[i], γ)
y[i] ~ Normal(mean = _y[i] + b, variance = 1.0)
end
end
_, y_data_un = generate_data(0.5, 25.0, 10.0, 250)
imarginals = @initialization begin
q(b) = NormalMeanVariance(0.0, 100.0)
q(x) = NormalMeanVariance(0.0, 1.0)
q(a) = NormalMeanVariance(0.0, 1.0)
q(γ) = GammaShapeRate(1, 1000)
q(_y) = NormalMeanVariance(0.0, 100.0)
end
results_unknown_x = infer(
model = linear_regression(),
data = (y = y_data_un,),
returnvars = (a = KeepLast(), x = KeepLast()),
initialization = imarginals,
constraints = MeanField(),
iterations = 20
) |
Beta Was this translation helpful? Give feedback.
-
Hi. If you look into Bayesian Network (software), as Bayes Server, you will find out that it is always estimating the distribution of the "inputs" condition to the other nodes. Check at Bayes Server. |
Beta Was this translation helpful? Give feedback.
-
I will transfer this issue into discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I looking for a way to do inference over the inputs of a model.
For example, for linear regression case, I looking for calculating x by assigning it
missing
and giving values ofy
.I see that the example Bike Rental example does similar by relating inputs with the states of a filter (I am looking for a simpler way).
Beta Was this translation helpful? Give feedback.
All reactions