# How to restrict positive posterior?

Is there a way to restrict posterior, say, to only positive values or an interval of values? Let's say I want to estimate a linear model, y = a + Xb, using Bayesian techniques. I specify priors for a and b, a ~ N(0, 1), b ~ N(0,1). When estimating posteriors, I might get that b= -0.3 with some probability. What I want to do is to restrict somehow posterior values so that they can only be positive or within some interval.

You only put prior mass on the region that you want the posterior to have mass over. So in your situation, if you want the posterior of $b$ to only take on positive values, you'd specify a prior for $b$ that only takes positive values. You can accomplish this by assigning a truncated normal distribution as a prior instead of a normal distribution, or you can use a distribution already only defined on the positive reals, like a gamma.