I am trying to program probabilistic branching in a stan framework.
I want to generate a sample from a distribution, then take actions based on the sign of this sample like in the code below.
// lets assume a and b are derived from data
mu ~ uniform(-10,10)
sigma ~ normal(2,1)
// d : generate sample from normal(mu, sigma)
d = normal_rng(mu, sigma)
if (d<0) {
s ~ normal(a, b)
}
if (d > 0) {
s ~ normal(a,b) + exponential(d)
}
Please guide me on the possibility of doing this in stan.