Saturday, June 12, 2010

Estimating Likelihood function (parametric)

Likelihood function or class-conditional probability $P({\bf x}|\omega_i)$ can be calculated directly from the data. The parametric approach is to assume that the data from each class comes from a normal distribution with its own mean and covariance. This means that we need to find the two parameters from the data of each class and use these parameters to evaluate the probability at $\bf x$.

\[P({\bf x}|\omega_i)=P({\bf x}|\mu_i,\sigma_i^2)\]

For example, using iris data, we first get the parameters of the setosa, versicolor and virginica class

load iris;

muset = mean(setosa);
muver=mean(versicolor);
muvir=mean(virginica);
covset=cov(setosa);
covver=cov(versicolor);
covvir=cov(virginica);

There are 50 samples from each class. Then, we test the iris classification into three classes.

X=[setosa;versicolor;virginica];
pset=mvnpdf(X,muset,covset);
pver=mvnpdf(X,muver,covver);
pvir=mvnpdf(X,muvir,covvir);

plot(pset,'b'), hold on;
plot(pver,'r');
plot(pvir,'g'); hold off;

The result is shown below (setosa, versicolor, virginica).

No comments:

Post a Comment