# [SciPy-user] computing Bayesian credible intervals

Bruce Southey bsouthey@gmail....
Tue May 6 15:47:57 CDT 2008

```Hi,
First what do you really mean by p(a) or p(b)?
I would think that you want the definition that Anne defines them and
as also implied by Robert's example.

For this case the posterior is most likely gamma or proportional to
one (it's been a while) which is asymmetric. (Note you will need to
follow the derivation to determine if the constant has been ignored
since it drops out of most calculations.)  So defining the
probabilities as p(x<a) and p(x>b) means that the points a and b are
not generally going to be equidistant from the center of the
distribution (mean, median and mode will give potentially different
but correct answers) and p(x<a) != p(x>b). In this case you must be
able to find the areas of the two tails. Obviously it is considerably
easier and more flexible to use the actual distribution than a vague
formula.

Bruce

On Tue, May 6, 2008 at 2:55 PM, Robert Kern <robert.kern@gmail.com> wrote:
> On Tue, May 6, 2008 at 2:18 AM, Anne Archibald
>  <peridot.faceted@gmail.com> wrote:
>  >  Do you really need p(a)=p(b)? I mean, is this the right supplementary
>  >  condition to construct a credible interval? Would it be acceptable to
>  >  choose instead p(x<a)=p(x>b)? This will probably be easier to work
>  >  with, at least if you can get good numerical behaviour out of your
>  >  PDF.
>
>  It's one of the defining characteristics of the kind of credible
>  interval Johann is looking for. "Bayesian credible interval" is a
>  somewhat broad designation; it applies to pretty much any interval on
>  a Baysian posterior distribution as long as the interval is selected
>  according to some rule that statisticians agree has some kind of
>  meaning.
>
>  In practice, one of the most common such rules is to find the "Highest
>  Posterior Density" (HPD) interval, where p(a)=p(b) and P(b)-P(a)=0.95
>  or some such chosen credibility level. Imagine the PDF being flooded
>  with water up to its peak (let's assume unimodality for now). We
>  gradually lower the level of the water such that for both points a and
>  b where the water touches the PDF, p(a)=p(b). We lower the water until
>  the integral under the "dry" peak is equal to 0.95. Then [a,b] is the
>  HPD credible interval for that PDF at the 0.95 credibility level.
>
>  --
>  Robert Kern
>
>  "I have come to believe that the whole world is an enigma, a harmless
>  enigma that is made terrible by our own mad attempt to interpret it as
>  though it had an underlying truth."
>   -- Umberto Eco
>
>
> _______________________________________________
>  SciPy-user mailing list
>  SciPy-user@scipy.org
>  http://projects.scipy.org/mailman/listinfo/scipy-user
>
```