📄 bayesnd.m
字号:
function [A,B,C]=bayesnd(P1,P2,M1,M2,C1,C2)
% BAYESND computes parameters of quadratic discriminat function.
% [A,B,C]=bayesnd(P1,P2,M1,M2,C1,C2)
%
% BAYESND calculates discrimination function for the classifier deciding
% according to maximum of aposteriori probability under the condition
% of dichotomic classification and normal distributions p(x|k).
% Discrimination function is quadratic
% x'*A*x + B'*x + C = 0.
%
% Input:
% P1 [1x1] - apriori probability of the class 1
% P2 [1x1] - apriori probability of the class 2
% M1 [Nx1] - column vector of mean valuses for p(x|k1), class 1.
% M2 [Nx1] - column vector of mean valuses for p(x|k2), class 2.
% C1 [NxN] - covariance matrix for p(x|k1), class 1.
% C2 [NxN] - covariance matrix for p(x|k2), class 2.
%
% where N is the dimension of the feature space.
%
% Output: parameters of the quadratic function
% A [NxN] - matrix
% B [Nx1] - column vector
% C [1x1] - scalar value
%
% See also BAYESCLN, PBAYESCLN.
%
% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Written Vojtech Franc (diploma thesis) 19.03.2000
% Modifications
% 24. 6.00 V. Hlavac, comments into English.
M1=M1(:);
M2=M2(:);
A=(1/2)*(inv(C2)-inv(C1));
B=(M1'*inv(C1)-M2'*inv(C2))';
% Treatment of the case when apriori probabilities are zero.
% log(0)=-inf;
if P1==0,
C=-inf;
elseif P2==0,
C=inf;
else
C=(1/2)*(M2'*inv(C2)*M2-M1'*inv(C1)*M1)+...
log(sqrt(det(C2)))-log(sqrt(det(C1)))+log(P1)-log(P2);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -