# Parameters of beta distribution with a given HDI [duplicate]

Is there some way to calculate the parameters of a beta distribution, if the highest density interval is known. That is, given $$a,b,x$$ I want to have a beta distribution such that the probability of the interval $$[a,b]$$ is $$x$$.

The reason I need this is that I want to use beta priors in a Bayesian analysis, to show how beliefs are updated by the data. So if someone is 95% certain that the true probability is between $$a$$ and $$b$$, then I want to construct a beta distribution that captures this belief as a prior.

• @COOLSerdash Unfortunately not. I want a complete interval to be covered with some probability, not just two points. I don't really care that much about the value of the distribution at the end points. – LiKao May 15 '20 at 12:10
• I recommend reading the linked answer more carefully: By setting the appropriate quantiles, it gets you what you want (I think). To give an example: An expert thinks that with 95% certainty, the true probability lies between $0.2$ and $0.75$. So the points we have are $(0.025, 0.2)$ and $(0.975, 0.75)$. whuber's code shows that a beta distribution with parameters $5.21$ and $5.88$ satisfies this request. Isn't this exactly what you want? – COOLSerdash May 15 '20 at 12:24
• @COOLSerdash Ah, you are right. I misread PDF instead of CDF in that question. If the points are on the CDF that does indeed answer my question. – LiKao May 18 '20 at 14:41

I'm not sure if you want to use beta distribution in here. Notice that if the $$[a,b]$$ interval is not symmetric around $$0.5$$, then the beta distribution covering such interval would not be symmetric as well. In such case, it would be skewed, and you would be assigning more prior density mass to some particular area within the $$[a,b]$$ interval. If the only thing that you want to assume that the value is within the $$[a,b]$$ interval, when this sounds more like assuming a mixture of uniform prior on $$[a,b]$$ and some other distribution.