Calculate posterior distribution of unknown mis-classification with PRTools in MATLAB
Posted
by Samuel Lampa
on Stack Overflow
See other posts from Stack Overflow
or by Samuel Lampa
Published on 2010-05-25T22:14:45Z
Indexed on
2010/05/25
22:41 UTC
Read the original article
Hit count: 312
I'm using the PRTools MATLAB library to train some classifiers, generating test data and testing the classifiers.
I have the following details:
- N: Total # of test examples
- k: # of mis-classification for each classifier and class
I want to do:
Calculate and plot Bayesian posterior distributions of the unknown probabilities of mis-classification (denoted q), that is, as probability density functions over q itself (so, P(q) will be plotted over q, from 0 to 1).
I have that (math formulae, not matlab code!):
P(q|k,N) = Posterior * Prior / Normalization constant =
P(k|q,N) * P(q|N) / P(k|N)
The prior is set to 1, so I only need to calculate the posterior and normalization constant.
I know that the posterior can be expressed as (where B(N,k) is the binomial coefficient):
P(k|q,N) = B(N,k) * q^k * (1-q)^(N-k)
... so the Normalization constant is simply an integral of the posterior above, from 0 to 1:
P(k|N) = B(N,k) * integralFromZeroToOne( q^k * (1-q)^(N-k) )
(The Binomial coefficient ( B(N,k) ) can be omitted thoughappears in both the posterior and normalization constant, so it can be omitted.)
Now, I've heard that the integral for the normalization constant should be able to be calculated as a series ... something like:
k!(N-k)! / (N+1)!
Is that correct? (I have some lecture notes from with this series, but can't figure out if it is for the normalization constant integral, or for the posterior distribution of mis-classification (q))
Also, hints are welcome as how to practically calculate this? (factorials are easily creating truncation errors right?) ... AND, how to practically calculate the final plot (the posterior distribution over q, from 0 to 1).
© Stack Overflow or respective owner