How are bounds handled by Stan?

I am curious to how upper/lower bounds on parameters are treated by Stan? Is it truncation, censoring or some other method? For example, in the following code, how would the constraint on rate be handled by the <lower = 0> bound?

data {
  int<lower = 1> N;
  real<lower = 0> obs[N]; 
}

parameters {
  real<lower = 0> rate;
}

model {
  rate ~ normal(3, 2); 

  for(n in 1:N){
    obs[n] ~ exponential(rate); 
  }
}

Obviously it is likely more appropriate to use a prior distribution that is positive continuous by definition, but this is for the sake of curiosity.

Under the hood, the parameter is transformed to an unconstrained parameter, in this case \theta = log(rate). The target density is then incremented by normal_lpdf(exp(theta) | 3, 2) as well as by the appropriate Jacobian adjustment, which in this case is just theta.

2 Likes