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

📄 testandr.m

📁 四种SVM工具箱的分类与回归算法别人的
💻 M
字号:
function [MI,SIGMA,J]=testandr(dim,epsilon,dnoise,maxcoord,diagm)% TESTANDR creates testing data for Generalized Anderson's task.% [MI,SIGMA,J]=testandr(dim,epsilon,dnoise,maxcoord,diagm)%% TESTANDR generates a test input set for the Generalized Anderson's %  task (GAT). It is intended for creating of test data for comparison %  of the algorithms solving GAT.%   % Input:%  dim [1x1]      dimension of the feature space.%  epsilon [1x1]  a probability of wrong classification for the optimal %                 solution, i.e. the minimal error which any algorithm can%                 achieve. The value of the epsilon must be 0 < epsilon <0.5%  dnoise [1x1]   a number of the additional distributions which do not%                 determine the optimal solution. A purpose of these %                 distributions is to make work of the evaluted algorithm%                 more difficult. Default value is dnoise=0.%  maxcoord [1x1] is a range the coordinates of mean values.%                 Default is maxcoord=10.%  diagm [1x1]    if diagm == 1 then the diagonal covariance matrix will be %                 used.%% Output:%  (denote K = (dim-1)*4+dnoise as number of the generated distributions ).%%  MI [dim,K]     contains the K vectors of mean values, %                 i.e. MI=[mi_1,mi_2,...mi_K].%  SIGMA [dim,dim*K] contains the covariance matrices,%                 i.e. SIGMA=[sigma_1,...,sigma_K].%  J [1,K]        contains class labels of given distribution - a pair of%                 mean value and covariance matrix. %% See also %   GANDERS, GANDERS2, EANDERS, OANDERS, GGANDES.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis)% Modifications% 26-feb-2001 V.Francif nargin < 2,  error('Not enought input parameters.');  return;endif nargin < 3,  dnoise=0;endif nargin < 4,  maxcoord=10;endif nargin < 5,  diagm=0;end if epsilon <=0 | epsilon >=0.5,  error('Input paramater epsilon is out of range.');  return;end% computes Mahalanobis distance in according to epsilonr=-icdf('norm',epsilon,0,1);alpha=zeros(dim,1);alpha(dim)=1;theta=0;K=(dim-1)*4+dnoise;MI=zeros(dim,K);   %MI=[];SIGMA=zeros(dim,dim*K);   %SIGMA=[];J=[];j=0;for i=1:dim-1,  clear mi sigma x0;    % ++  j=j+1;  sigma=randpds(dim,diagm); %  sigma=gcov(dim);  mi=zeros(dim,1);  mi(i)=maxcoord*rand(1);%  if (size(alpha,1)~=size(sigma,1)),%     alpha%     sigma%  end  mi(dim)=r*sqrt(alpha'*sigma*alpha);    % enusures that the mi(i) coordinates will have a right sign  x0=mi-(alpha'*mi)*sigma*alpha/(alpha'*sigma*alpha);  if x0(i) < 0, x0(i)=-x0(i); end    MI(:,j)=mi;   % MI=[MI,mi];  SIGMA(:,(j-1)*dim+1:dim*j)=sigma;  %SIGMA=[SIGMA,sigma];  J=[J,1];        % +-  j=j+1;%  sigma=gcov(dim);  sigma=randpds(dim,diagm);  mi=zeros(dim,1);  mi(i)=-maxcoord*rand(1);  if (size(alpha,1)~=size(sigma,1)),     alpha     sigma  end  mi(dim)=r*sqrt(alpha'*sigma*alpha);  % enusures that the mi(i) coordinates will have a right sign  x0=mi-(alpha'*mi)*sigma*alpha/(alpha'*sigma*alpha);  if x0(i) > 0, x0(i)=-x0(i); end    MI(:,j)=mi;   % MI=[MI,mi];  SIGMA(:,(j-1)*dim+1:dim*j)=sigma;  %SIGMA=[SIGMA,sigma];  J=[J,1];  % -+  j=j+1;%  sigma=gcov(dim);  sigma=randpds(dim,diagm);  mi=zeros(dim,1);  mi(i)=maxcoord*rand(1);  if (size(alpha,1)~=size(sigma,1)),     alpha     sigma  end  mi(dim)=-r*sqrt(alpha'*sigma*alpha);%  size(alpha)%  size(sigma)  % enusures that the mi(i) coordinates will have a right sign  x0=mi-(alpha'*mi)*sigma*alpha/(alpha'*sigma*alpha);  if x0(i) < 0, x0(i)=-x0(i); end    MI(:,j)=mi;   % MI=[MI,mi];  SIGMA(:,(j-1)*dim+1:dim*j)=sigma;  %SIGMA=[SIGMA,sigma];  J=[J,2];  % --  j=j+1;%  sigma=gcov(dim);  sigma=randpds(dim,diagm);  mi=zeros(dim,1);  mi(i)=-maxcoord*rand(1);  if (size(alpha,1)~=size(sigma,1)),     alpha     sigma  end  mi(dim)=-r*sqrt(alpha'*sigma*alpha);    % enusures that the mi(i) coordinates will have a right sign  x0=mi-(alpha'*mi)*sigma*alpha/(alpha'*sigma*alpha);  if x0(i) > 0, x0(i)=-x0(i); end      MI(:,j)=mi;   % MI=[MI,mi];  SIGMA(:,(j-1)*dim+1:dim*j)=sigma;  %SIGMA=[SIGMA,sigma];  J=[J,2];endfor i=1:dnoise,  j=j+1;  mi=rand(dim);%  sigma=gcov(dim);  sigma=randpds(dim,diagm);  % makes mi to be in the first subspace  if (alpha'*mi) < 0, mi=-mi; end    rr=(alpha'*mi)/sqrt(alpha'*sigma*alpha);     rnoise=r+rand(1)/2;  mi=mi*rnoise/rr;     if rand(1) < 0.5,    J=[J,1];  else    J=[J,2];    mi=-mi;  end  MI(:,j)=mi;   % MI=[MI,mi];  SIGMA(:,(j-1)*dim+1:dim*j)=sigma;  %SIGMA=[SIGMA,sigma];end

⌨️ 快捷键说明

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