I want to test a math function ,like y=x1+x2 , but no observed data.
x1=pm.Normal(‘x1’,mu=0.5,sd=0.5)
x2=pm.Normal(‘x1’,mu=0.5,sd=0.5)
y=x1+x2
Y=pm.Normal(‘Y’,mu = y,sd=1,observed =obs)
so how to define reasonable observed data? and why ?
I want to test a math function ,like y=x1+x2 , but no observed data.
x1=pm.Normal(‘x1’,mu=0.5,sd=0.5)
x2=pm.Normal(‘x1’,mu=0.5,sd=0.5)
y=x1+x2
Y=pm.Normal(‘Y’,mu = y,sd=1,observed =obs)
so how to define reasonable observed data? and why ?
Not sure I understand your question, but if the function is not directly observed, and you want to do inference on this latent variable, the code you wrote above is correct.
I don’t understand this question either.
I mean there is no observed data. so may I run it with no observed data. if not, how to define the observed data?
x1=pm.Normal(‘x1’,mu=0.5,sd=0.5)
x2=pm.Normal(‘x2’,mu=0.5,sd=0.5)
y=x1+x2
Y=pm.Normal(‘Y’,mu = y,sd=1)
I still don’t understand what you are asking. If you run the model you defined in your last post, it will sample from the priors on x1
, x2
, and Y
. There is no connection and no observations defined, so your traces of the three parameters should be independent. The model will also sample y
from its implicit prior.
Do you mean sampling from the prior predictive? If so, you can do:
with pm.Model() as model:
x1 = pm.Normal('x1', mu=0.5, sd=0.5)
x2 = pm.Normal('x2', mu=0.5, sd=0.5)
y = pm.Deterministic('y', x1 + x2)
with model:
trace = pm.sample(1000)
and then look at the trace of y
.
Isn’t that the prior? I don’t understand the difference.
oh, thanks very much. I maybe wrong that I think It’s necessary to define oberserved data.