Skip to content
MthwRobinson edited this page Dec 21, 2014 · 1 revision

Bayesian Procedures

APPLPy includes a number of procedures designed to aid with Bayesian parameter estimation. These procedures emphasize the computation of exact distributions for parameters given a distribution with one unknown parameter, a prior distribution for the unknown parameter and a data set.

Credible Sets

Given a posterior distribution for a unknown parameter, the CredibleSet procedures computes a credible set for the unknown parameter, where alpha is the confidence level. The procedures produces the credible set as a list, where the first number is the alpha/2 percentile of the posterior distribution and the second number is the 1-(alpha/2) percentile of the posterior distribution.

Syntax

CredibleSet(X,alpha)

Examples:

n [15]: theta=Symbol('theta')

In [16]: X=BinomialRV(12,theta)

In [17]: Y=TriangularRV(0,1/2,1)

In [18]: data=[5]

In [19]: P=Posterior(X,Y,data,theta)

In [20]: CredibleSet(P,0.5)
Out[20]: [0.366791756376279, 0.522235033985543]

Posterior Distributions

The posterior procedure computes the posterior distribution for an unknown parameter given a likelihood function, a prior distribution, a data set and an unknown parameter. When the posterior distribution is produced as output, the distribution will display the unknown parameter as x. This enables the random variable to remain compatible with the remainder of APPLPy, whose symbolic procedures assume that distributions are a function of x.

Syntax

Posterior(X,Y,[data])

Examples:

In [21]: theta=Symbol('theta')

In [22]: X=BinomialRV(12,theta)

In [23]: Y=TriangularRV(Rational(0),Rational(1,2),Rational(1))

In [24]: data=[5]

In [25]: P=Posterior(X,Y,data,theta)

In [26]: P.display()
continuous pdf
for 0 <= x <= 1/2
---------------------------
           6        7 
-36900864x ⋅(x - 1)  
──────────────────────
         1363         
---------------------------
 
 
for 1/2 <= x <= 1
---------------------------
          5        8
36900864x ⋅(x - 1) 
────────────────────
        1363        
---------------------------
Clone this wiki locally