资源简介
贝叶斯最小错误分类器matlab code。 样品正态分布, 最大似然估计参数
代码片段和文件信息
train=load(‘q1pt1train.txt‘); %load trainning data
test=load(‘q1pt1test.txt‘); %load test data
train1=zeros(14);
train2=zeros(14);
sumtrain1=zeros(14);
sumtrain2=zeros(14);
%get mean u1 from training data--------
for i=1:7500
train1=train(i:);
sumtrain1=sumtrain1+train1;
end
meantrain1=(1/7500)*sumtrain1;
%--------------------------------------
%get mean u2 from training data--------
for i=7501:15000
train2=train(i:);
sumtrain2=sumtrain2+train2;
end
meantrain2=(1/7500)*sumtrain2;
%---------------------------------------
%get covariance matrix of w1 from trainning data
conv1=zeros(14);
conv2=zeros(14);
sumcov1=zeros(44);
sumcov2=zeros(44);
covariance1=zeros(44);
covariance2=zeros(44);
for i=1:7500
conv1=(train(i:)‘-meantrain1‘)*((train(i:)‘-meantrain1‘)‘);
sumcov1=sumcov1+conv1;
end
convariance1= (1/(7500-1))*sumcov1;
%-------------------------------------------
%get covariance matrix of w2 from trainning data
for i=7501:15000
conv2=(train(i:)‘-meantrain2‘)*((train(i:)
- 上一篇:TDOA算法室内定位
- 下一篇:170421NMS算法matlab程序
评论
共有 条评论