Hi,

I’ve got a question regarding implementation of a model where an observed variable can be described as a function of other random variables. My issues here are perhaps just due to my inexperience in using probabilistic programming rather than a problem specific to Turing, so any help is appreciated. In particular I have a problem where an observed quantity I is given by a function of the form:

I=A\cos(\phi)+B

where \phi\sim \mathcal{N}(\mu_1,\sigma_1) and \phi\sim \mathcal{N}(\mu_2,\sigma_2). Model parameters are then A,\mu_1,\sigma_1,\mu_2,\sigma_2. I could in principle derive the distribution for I, I\sim\mathcal{F}(A,\mu_1,\sigma_1,\mu_2,\sigma_2), and construct a Turing model like

```
@model function offset_model(y)
A ~ Uniform(0,100)
mu1 ~ Uniform(0,100)
sigma1 ~ Uniform(0,100)
mu2 ~ Uniform(0,100)
sigma2 ~ Uniform(0,100)
# The number of observations.
N = length(y)
for n in 1:N
y[n] ~ F(A,mu1,sigma1,mu2,sigma2)
end
end;
```

And using this, for a set of observations of I, I could then draw the posteriors for my model parameters.

But I’m wondering if there is some way to do this automatically in julia+turing without having to derive what would be a pretty complex distribution function for I. In particular, a flexible way to specify things would be useful as \phi or B can potentially follow different distributions, and having to derive the corresponding distributions for I can be very cumbersome.

As said before, any help is greatly appreciated!