% db  Dichotomy function
% 
% fdb = db(x,Pc1,Pc2,C1,C2,M1,M2) 
% 
% Inputs: 
% x [2x1]  point to be classified
% Pc1, Pc2 prior probabilities of classes
% C1,C2    covariance matrices of classes from training set
% M1,M2    means of classes from training set
%
% returns
% fdb < 0 if x is classified to the class 1
% fdb > 0 if x is classified to the class 2

function fdb = db(x,Pc1,Pc2,C1,C2,M1,M2) 

x  = x(:);
M1 = M1(:);
M2 = M2(:);

fdb = log(Pc2/Pc1) - log(det(C2)/det(C1)) - 1/2*(x-M2)'*inv(C2)*(x-M2) + 1/2*(x-M1)'*inv(C1)*(x-M1);
