⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dst.m

📁 DS证据推理的原始Dempster组合公式计算函数
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   The coryright belongs to Yang Yang,Automation Institute,NPU,710072
%   Xi'an, China      
%   EDITION NUMBER: 1.5
%   Contract me : E-mail yay9096@hotmail.com ,
%                 Mobile : 13572239439,
%                 Home :   029-82375332
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = DST(varargin)
%   calculate Dempster's rule, the format is:
%  [M,Q]=DST(e1,e2,e3,e4) or [M,Q]=DST(e1,e2,e3) or  M=DST(e1,e2)
%   and so no.
%   e1,e2,e3,e4: evidences to be combined,they are all vector for a  column.
%   M:     output combined basic belief assignments  for a  column
%   Q:     conflict rate for a number
% Interpretion:
%   The function can only calculate two or three classes for the Frame.If
%   the Frame have two elements, they are denoted in Theta={A,B},and if it
%   have three elements,the Theta={A,B,C}. Then the 2^Theta={0,A,B,AB}
%   for  two dimensions,and the  2^Theta={0,A,B,AB,C,AC,BC,ABC} for three  
%   classes .In the representation,A or B or C is represented by ABC,and
%   others can be understand in this way. Then the Dempster's rule can
%   be calculate in matrix .The evidences can be denoted in 
%   evdence1=[m1(0),m1(A),m1(B),m1(AB)],and
%   evdence1=[m2(0),m2(A),m2(B),m2(AB)] in the real world. m1(AB) is
%   represented by AB1, others can be understand in this way. 

%   Do not hesitate to contract  me ,if you have any question.

%   该1.5版本函数库具有一下功能和特点
%   1.支持多输入,即可同时组合不超过4个证据的情况;
%   2.支持多输出,即对于可以输出冲突率的公式还可以输出矛盾因子,或可信度系数等;
%   3.支持多维证据组合,即只要组合证据的维数不超过10维(即辨识框架的维数n),且每个
%     证据的排列符合二进制排序法(可参照下面的英文注释,在二进制数为2^(n-1)的位置是
%     第n个单假设焦元),且每个证据的大小一致,为列向量,就可以运用该函数计算证据组合。
      
% The elements of mass function are put in binary order for computing convenience.
% It means that the first element of mass empty set is denoted binary 000,and
% a is denoted binary 001,b is denoted binary 010,ab is denoted binary 011,
% c is denoted binary 100,ac is denoted binary 101,bc is denoted binary 110
% abc is denoted binary 111, for 3 class frame.And 2 class frame can be
% denoted in the same way.

% nargin表示输入证据的总数
for i=1:nargin
    [row(i),col(i)]=size(varargin{i});
end
row_num=row(1);
row=row-row_num;
if any(row)~=0
    disp('输入的证据维数不一致');
    return;
end
%Judge the classes of the Frame
row=row_num;
switch row
    case 4,
        class=2;
    case 8,
        class=3;
    case 16,
        class=4;
    case 32,
        class=5;
    case 64,
        class=6;
    case 128,
        class=7;
    case 256,
        class=8;
    case 512,
        class=9;
    case 1024,
        class=10;
    otherwise,
        disp('输入证据的维数超过计算范围(维数<=10),或焦元的排列顺序和大小不正确');
        return;
end

sum_chong = 0;
sum_zong = 0;

% 开始组合公式的运算
     m1=[0:row-1];
     switch nargin
         case 2,   
              M=zeros(row,1);
            Q=0;
            for i=1:row
                for j=1:row
                    sum_zong = sum_zong+1;
                        switch bitand(m1(i),m1(j))
                            case 0,
                                Q=Q+varargin{1}(i)*varargin{2}(j);
                                sum_chong = sum_chong+1;
                            case row-1,
                                M(row)=M(row)+varargin{1}(i)*varargin{2}(j);
                            otherwise,
                                 num1=bitand(m1(i),m1(j))+1;
                                 M(num1)=M(num1)+varargin{1}(i)*varargin{2}(j);
                        end                        
                 end
             end              
             if Q==1
                disp('证据完全冲突,冲突率等于1,不能组合');
                return
             end
             K=1-Q;
             M=M/K;
         case 3,
            M=zeros(row,1);
            Q=0;
            for i=1:row
                for j=1:row
                    for k=1:row
                        sum_zong = sum_zong+1;
                        switch bitand(m1(i),bitand(m1(j),m1(k)))
                             case 0,
                                Q=Q+varargin{1}(i)*varargin{2}(j)*varargin{3}(k);       
                                sum_chong = sum_chong+1;
                            case row-1,
                                M(row)=M(row)+varargin{1}(i)*varargin{2}(j)*varargin{3}(k);
                            otherwise,
                                num1=bitand(m1(i),bitand(m1(j),m1(k)))+1;
                                M(num1)=M(num1)+varargin{1}(i)*varargin{2}(j)*varargin{3}(k);               
                        end
                    end
                end
            end              
            if Q==1
                disp('证据完全冲突,冲突率等于1,不能组合');
                return
            end
            K=1-Q;
            M=M/K;
        case 4,
           M=zeros(row,1);
           Q=0;
           for i=1:row
                for j=1:row
                    for k=1:row
                        for l=1:row
                            sum_zong = sum_zong+1;
                           switch bitand(m1(i),bitand(m1(j),bitand(m1(k),m1(l))))
                              case 0,
                                  Q=Q+varargin{1}(i)*varargin{2}(j)*varargin{3}(k)*varargin{4}(l);
                                   sum_chong = sum_chong+1;
                              case row-1,
                                  M(row)=M(row)+varargin{1}(i)*varargin{2}(j)*varargin{3}(k)*varargin{4}(l);
                              otherwise,
                                  num1=bitand(m1(i),bitand(m1(j),bitand(m1(k),m1(l))))+1;
                                  M(num1)=M(num1)+varargin{1}(i)*varargin{2}(j)*varargin{3}(k)*varargin{4}(l);              
                           end
                       end
                  end
              end
          end
              if Q==1
                  disp('证据完全冲突,冲突率等于1,不能组合');
                    return
              end
              K=1-Q;
              M=M/K;
        otherwise,
             disp('该函数只能计算组合2,3或4个证据,且辨识框架为不超过10维的证据,请检查是否证据个数是否在该范围内!')     
             return;   
     end             

 varargout{1}=M;
 varargout{2}=Q;
     
 
 
     
%  sum_zong
% sum_chong

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -