%PROBCLASS Classification based on conditional pdfs
%function [dataclass,dataprobs]=probclass(data,v1,v2,pdftbl)
%Get probabilities (dataprobs) and most likely class (dataclass)
%data: data point to be classified Nx2 matrix
%v1, v2, vectors defining bins of pdf table
%pdftbl: pdf table, e.g. may be obtained from condpdfs 
%        matrix of size length(v1) x length(v2) x number_of_classes

%written by Tapan Mukerji

ndat=length(data(:,1)); ncat=size(pdftbl,3); dataprobs=zeros(ndat,ncat);

for k=1:ndat
 i1=sum(data(k,1)>v1); if i1==0, i1=i1+1; end;
 i2=sum(data(k,2)>v2); if i2==0, i2=i2+1; end;
 dataprobs(k,:)=squeeze(pdftbl(i1,i2,:)).';
end;
[maxprob,dataclass]=max(dataprobs,[],2);
