Hello,
I like to build a model, which uses Bayesian Inference to infer the true air speed tas
based on observations of the ground speed gs
and wind speed wind
.
For gs
, I can assume it to be Gaussian due to measurement error. Assuming a constant sigma
, I’ll get a model for this part like this:
import pymc as pm
import numpy as np
speeds = np.array([190.0, 181.2, 202.5])
with pm.Model() as model:
mean_gs = pm.Uniform("mean_gs", lower=0, upper=200)
sigma_gs = 2.0
gs = pm.Normal("gs", mu=mean_gs, sigma=sigma_gs, observed=speeds)
This is just based on the PyMC tutorial and Bayesian Methods for Hackers. It works as expected. The result is a posterior which represent probable values for mu
of the gs
Normal distribution.
Now I like to add ws
to obtain tas = gs + wind
as a distribution. (This is obviously a simplification from a physical standpoint, but ok for the demonstration here.)
I tried it like this:
with pm.Model() as model:
mean_gs = pm.Uniform("mean_gs", lower=0, upper=200)
sigma_gs = 5.0
mean_wind = pm.Uniform("mean_wind", lower=10, upper=40)
sigma_wind = 2.0
wind = pm.Normal('wind', mu=mean_wind, sigma=sigma_wind)
gs = pm.Normal("gs", mu=mean_gs, sigma=sigma_gs, observed=speeds)
tas = pm.Deterministic('tas', gs + wind)
But then the result are three different posteriors for tas
, because I have three observations (will be 5, with 5 observed and so on). If I’ll add observed values to wind
, they have to be the same dimension as the observed for gs
, otherwise I’ll get an error.
So obviously, this is not the right approach to my problem. However, I couldn’t find any examples for such use cases with contentious distributions and observations from multiple sources. How would I implement such problems with PyMC? Do I need three models, one for gs
, one for ws
and a third to merge the results of the first two?
Thank you for your thoughts!