 # Observed data is formula of 2 random variables

Hello,

I would like to know if it is possible to infer incase the observed data is a function of two (or more) random variables?

So e.g. I have the following data:

``````true_prob = 0.3
true_dist = dist.Bernoulli(true_prob)

observed = dist.Normal(true_dist.sample_n(2000), 1.0).sample()
observed # tensor([ 1.2886, -1.2316, -1.1521,  ..., -0.6966,  1.0491,  2.1959])
``````

Now I want to estimate the true prob from the output. The following works:

``````def model(data):
probability = pyro.sample("probability", dist.Uniform(0.0, 1.0))

with pyro.plate("observed_data"):
a = pyro.sample("a", dist.Bernoulli(probs=probability))
pyro.sample(f"obs", dist.Normal(a, 1.0), obs=data)
mcmc = MCMC(nuts_kernel, num_samples=4000, warmup_steps=300)
mcmc.run(observed)
mcmc.get_samples()["probability"].mean() # tensor(0.3305)
``````

Now instead of trying to estimate the variables as they are dependent, my observed data is the sum (which is really similar but this is just an example)

``````def underlying_model():
probability = pyro.sample("probability", dist.Uniform(0.0, 1.0))

with pyro.plate("observe_data"):
a = pyro.sample("a", dist.Bernoulli(probs=probability))
b = pyro.sample("b", dist.Normal(0.0, 1.0))

pyro.deterministic("x", a + b)
conditioned_model = poutine.do(underlying_model, data={"x": observed})