亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mds.m

?? 一個(gè)計(jì)算多維定標(biāo)(MDS)的matlab源代碼
?? M
字號(hào):
function [ Config,DHS,DS,DeltaS,Stress1,StressT1,Stress2,StressT2,Rs,RsT] = ...
              mds( userinput,TrainMatrix,TestMatrix,NTests )

global l Config no nt ns r DHS DS DO sortindex DeltaS referindex;
global effected effecteds oldsum1 oldsum2 noteffecteds;
global minoption;

r           = userinput{2};
nt          = userinput{3};
maxiter     = userinput{4};
convcrit    = userinput{5};
doprint     = userinput{6};
dograph     = userinput{7};
dospecific  = userinput{8};
startoption = userinput{9};
plot3dok    = userinput{10};
seed        = userinput{11};
dosym       = userinput{13};
dotest      = userinput{14};
minoption   = userinput{15};

DistsSub    = TrainMatrix; 

if (nt<1) 
   error( 'Number of dimensions must be bigger than 1' );
end

no = size( DistsSub , 1 ); % no is the Number of Objects 

if (no < 2)
   error('Loaded a similarity matrix with less than two objects' );
end

if dotest~=1
   StressT1 = 1.0;
   StressT2 = 1.0;
   RsT      = 0.0;
end

% do we symmetrize the matrix?
if dosym==1
   DistsSub = symmetrize( DistsSub );   
end

% manipulate the subjects' rating so that the triangular inequality and
% positivity holds

c1 = 0;
c2 = 0;
if (startoption==0)
   % make a random start configuration
   randn( 'state',seed );
   Config = randn( no , nt ); % draw from normal distribution
else
   % make an initial configuration with Torgeson-Young scaling
   
   %old code [DistsSub,c1,c2]    = manipulate( no , DistsSub  );
   [DistsSub,c1,c2] = ManipulateC( DistsSub,no  );
   Config = calcratconfig( nt , no , DistsSub );
end

% convert these two dimensional arrays to single dimension arrays
ns = no * (no - 1) / 2; % ns is #entries in single dimension array

Delta      = zeros( ns , 1 ); % the subjects' data 
DO         = zeros( ns , 1 ); % the distances of the start configuration
referindex = zeros( no , no );

ind = 0; % ind is the index
for i=1:no-1
   for j=i+1:no
      ind = ind + 1;
      Delta( ind )      = DistsSub( i,j );  
      DO( ind )         = Mink( Config( i,: ) , Config( j,: ) , r );
      
      referindex( i,j ) = ind;
   end
end

% figure out what indices are effected when object l is referred to
% this will speed up several processes
effected  = zeros( no , no-1 );
effecteds = zeros( no , no-1 );

for l=1:no
  count = 0; 
  if (l<no)
    i=l;
    for j=i+1:no
      ind = referindex( i,j );
      count = count + 1;
      effected( l , count ) = ind; 
    end
  end  

  if (l>1)
    j=l;
    for i=1:j-1;
      ind = referindex( i,j );
      
      count = count + 1;
      effected( l , count ) = ind;
    end
  end   
end

% sort the subjects' dissimilarity array
[DeltaS,sortindex]=sort( Delta );

% update the effected array to incorporate this order
[dummy,newindex] = sort( sortindex );
wholelist = 1:ns;
noteffecteds = zeros( no , ns - no + 1 );
for l=1:no
   for i=1:no-1
      effecteds( l,i ) = newindex( effected( l,i ));
   end
   
   notinlist = setdiff( wholelist , effecteds( l,:) );
   noteffecteds( l,: ) = notinlist;
end

% and sort the distances accordingly
DS = DO(sortindex);

% calculate the d-hats from the distances with Kruskal's upward-downward algorithm
[DHS,inblock,ave,rsum,nmem] = calcdhatsc( ns , DS );

% calculate stress
[Stress1,Stress2] = calcstress( DS , DHS );

% calculate the spearman rankorder correlation coefficient
Rs = compute_rank( ns , DS , DeltaS );

if dograph==1
   showplots( 0 , Stress1 , Stress2 , plot3dok );
end;   
   
% do the optimization of the coordinates

if doprint==1
   % print some statements about the initial status of the MDS program
   fprintf( 'Values added to satisfy distance axioms %g %g\n' , c1 , c2 );
   fprintf( 'Minkowski metric r value                %g\n'   , r );
   fprintf( 'Number of objects in matrix             %d\n'   , no );
   fprintf( 'Number of useful similarity ratings     %d\n'   , ns );
   fprintf( 'Number of dimensions:                   %d\n\n' , nt ); 
   fprintf( 'Maximum number of iterations            %d\n' , maxiter  );
   fprintf( 'Convergence Criterion:                  %g\n' , convcrit );
   fprintf( 'Minimize function:                      stress%d\n' , minoption );
   fprintf( 'Starting configuration is:              ' );
   
   if (startoption==0)
      fprintf( 'random  (seed=%d)\n' , seed );
   else
      fprintf( 'Torgeson-Young' );
   end
   
   fprintf( '\n\n' );
   fprintf( 'The following results apply to training file only:\n' );
   fprintf( '(Rs is the rank order correlation coefficient\nbetween observed and predicted dissimilarities\n\n' );
   fprintf( 't=0 Stress1=%1.5f Stress2=%1.5f Rs=%1.5f\n' , Stress1 , Stress2 , Rs );
end

iter     = 0;
stopiter = 0;

if (iter==maxiter) 
   stopiter=1;
end

while (stopiter==0);
   iter=iter+1;
   
   if (iter==maxiter)
      stopiter=1;
   end
   
   % on each iteration, move all points around
   optimize( dospecific );
   
   % calculate the new distances for the updated configuration
   ind = 0; % ind is the index
   for i=1:no-1
      for j=i+1:no
         ind = ind + 1;
         DO( ind ) = Mink( Config( i,: ) , Config( j,: ) , r );
      end
   end
 
   % and sort the distances according to subjects sorted array
   DS = DO(sortindex);
   
   % calculate the new d-hats from the distances with Kruskal's upward-downward algorithm
   [DHS,inblock,ave,rsum,nmem] = calcdhatsc( ns , DS );
   
   % calculate new stress
   if iter>1
      if minoption==1
         LastStress = Stress1;
      else
         LastStress = Stress2;
      end
   end;   
   
   [Stress1,Stress2] = calcstress( DS,DHS );
   
   if isnan( Stress1 )
      error( 'A NaN occured in calculations (1)' );
   else
     % What is the change with respect to last Stress Value
     if iter>1
        if minoption==1
           Change = ( LastStress - Stress1 );
        else
           Change = ( LastStress - Stress2 );
        end
        
        if Change < convcrit 
           stopiter = 2;
        end
     end;
        
     % calculate the spearman rankorder correlation coefficient
     Rs = compute_rank( ns , DS , DeltaS );
          
     if (doprint==1)
       fprintf( 't=%d Stress1=%1.5f Stress2=%1.5f Rs=%1.5f\n' , iter , Stress1 , Stress2 , Rs );
     end
   
     if dograph==1
       showplots( iter , Stress1 , Stress2 , plot3dok );  
     end;
   end 
end

if (dotest==1) & (stopiter~=3)
   
   if (doprint==1)
     fprintf( '\n\n' );
   end
   
   no_t = size( TestMatrix , 2 );
      
   if (no_t ~= no) 
      error( '# objects in validation matrix unequal to # objects in calibration matrx' );
   end   
      
   StressT1 = zeros( 1,NTests );
   StressT2 = zeros( 1,NTests );
   RsT      = zeros( 1,NTests );
   
   for s=1:NTests
      
      if (NTests==1)
         DistsSubT = squeeze( TestMatrix( 1  , : , : ));
      else
         DistsSubT = squeeze( TestMatrix( s  , : , : ));
      end
      
      if dosym==1
         DistsSubT = symmetrize( DistsSubT );
      end
      
      DeltaT = zeros( ns , 1 );
      
      ind = 0; % ind is the index
      for i=1:no-1
         for j=i+1:no
            ind = ind + 1;
            
            DeltaT( ind ) = DistsSubT( i,j );
         end
      end
      
      [DeltaST,sortindexT]=sort( DeltaT );
      
      % calculate the d-hats for the test data
      DS_T = DO(sortindexT);
      [DHS_T,inblock,ave,rsum,nmem] = calcdhatsc( ns , DS_T );
      
      % calculate new stress
      [ StressT1(s) , StressT2(s) ] = calcstress( DS_T,DHS_T );
      
      if isnan( StressT1(s) )
         error( 'A Nan occurred here' );
      end
            
      % calculate the spearman rankorder correlation coefficient
      RsT(s) = compute_rank( ns , DS_T , DeltaST );
      
      if (doprint==1)
         fprintf( 'S=%d Stress1=%1.5f Stress2=%1.5f Rs=%1.5f\n' , s , StressT1(s) , StressT2(s) , RsT(s) );
      end   
   end
end

if doprint==1
   fprintf( '\nEnd of simulation - reason: ' );
   if (stopiter==1) 
      fprintf( 'maximum number of iterations reached\n\n' );
   elseif (stopiter==2)
      fprintf( 'convergence criterion reached\n\n' );
   elseif (stopiter==3)
      fprintf( 'a NaN occured in stress computation\n\n' );
   
   end   
end

clear DistSub
%-----------------end of mds function----------------------------------



%----------------------------------------------------------------------
function  optimize( dospecific );
% optimize Stress for each point separately but jointly over each dimension

global l Config no nt ns r DHS DO DS sortindex oldsum1 oldsum2;
global noteffecteds;

options(1)=-1;

for l=1:no
   % optimize position of point l
   
   [oldsum1,oldsum2 ] = NotEffectedC( noteffecteds , DS , DHS , l , ns , no );
      
   x0 = Config(l,:); 
   warning off;
   % using the matlab program sopt2 that calls a C function
   x  = fminu( 'sopt2',x0,options  );
   warning on;
   Config(l,:)=x;
  
   % center all dimensions again
   for e=1:nt
     Config(:,e) = Config(:,e) - mean( Config(:,e) );
   end
   
   % and rescale
   Config = Config / std2( Config );
end



%--------------------------------------------------------------------
function showplots( iter , Stress1 , Stress2 , plot3dok );

global Config DeltaS DHS DS no nt;

% plot the d's and d-hats vs. the data
figure( 1 );
subplot( 1,2,1 );

if (nt==1)
   plot( Config(:,1) , Config(:,1) , 'r*' );
   grid on;
   axis square;
   xlabel( 'dimension 1' );
   ylabel( 'dimension 1' );
   
   for i=1:no
      text( Config(i,1)+0.1 , Config(i,1) , [sprintf( '%d' , i )] );
   end;   
elseif (nt==2)
   plot( Config(:,1) , Config(:,2) , 'r*' );
   grid on;
   axis square;
   xlabel( 'dimension 1' );
   ylabel( 'dimension 2' );
   
   for i=1:no
      text( Config(i,1)+0.1 , Config(i,2) , [sprintf( '%d' , i )] );
   end;   
elseif (nt>2) & (plot3dok==1)
   plot3( Config(:,1) , Config(:,2) , Config(:,3) , 'r*' );
   grid on;
   axis square;
   hold on;
   
   for i=1:no
      plot3( [Config(i,1) Config(i,1)] , [Config(i,2) Config(i,2)] , [ 0 Config(i,3)] , 'k' );
   end
   
   hold off;
   
   xlabel( 'dimension 1' );
   ylabel( 'dimension 2' );
   zlabel( 'dimension 3' );
   
   for i=1:no
      text( Config(i,1)+0.1 , Config(i,2) , Config(i,3) , [sprintf( '%d' , i )] );
   end;  
end

title( sprintf( 'Configuration after %d iterations' , iter ));

subplot( 1,2,2 );
plot( DS , DeltaS , 'r*' , DHS , DeltaS , '-gs' );
grid on;
axis square;
axis tight;
ylabel( 'dissimilarities data' );
xlabel( 'd' );
title( [ sprintf( 'Stress1=%1.4f Stress2=%1.4f ' , Stress1 , Stress2 ) ] );

drawnow;


%--------------------------------------------------------------------
function Config = calcratconfig( nt , no , DistsSub );
I = eye( no );
U = ones( no );
Z = I - (1/no) * U;
D = DistsSub.^2;
% convert the distances to inner products assuming centroid origin
B = -0.5 * Z * D * Z;

% do a eigenvector decomposition of B ( B = X * X' )
[V,D]=eig(B);
DD = diag( D );
[DDS,index]=sort(-DD);
DDS=-DDS;

DS=D(:,index);
VS=V(:,index);

% if we want n dimensions, there should be n positive eigenvalues
if DS(nt) < 0
   warning( 'negative eigenvalue in matrix: decrease number of dimensions' );
end

DS = DS(:,1:nt);
DS = DS.^0.5;

Config=VS*DS;

% normalize the variance of this starting configuration
Config = Config / std2( Config );


%--------------------------------------------------------------------
function [KSS1,KSS2,SStress] = calcstress( DOS , DHS );
% Kruskal's Stress formula 1
S1a  = sum( (DOS - DHS).^2 );
T1a  = sum( DOS.^2 );
KSS1 = sqrt( S1a / T1a ); 

% Kruskal's Stress formula 2
avDOS = mean( DOS );
T1a   = sum( ( DOS - avDOS ) .^ 2 );
KSS2  = sqrt( S1a / T1a );

% SStress
S1a     = sum( (DOS.^2 - DHS.^2).^2 );
T1a     = sum( DOS.^4 );
SStress = sqrt( S1a / T1a ); 

%--------------------------------------------------------------------
function d=Mink( x , y , r )
d1 = abs(x - y);
d = sum( d1.^r ) ^ (1/r);

%--------------------------------------------------------------------
function D = symmetrize( D );
global no;

for i=1:no-1
   for j=i+1:no
      rating1 = D( i,j );
      rating2 = D( j,i );
         
      newrating = (rating1 + rating2) / 2;
         
      D(i,j) = newrating;
      D(j,i) = newrating;
   end
end
   
for i=1:no
  D(i,i) = 0;
end





?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲精品一区二区三区| 久久精品国产**网站演员| 中文欧美字幕免费| 久久人人超碰精品| 久久精品一二三| 久久精品亚洲麻豆av一区二区| 精品第一国产综合精品aⅴ| 精品国产91乱码一区二区三区 | 精品欧美一区二区三区精品久久| 678五月天丁香亚洲综合网| 9191国产精品| 欧美成人精品3d动漫h| 欧美不卡在线视频| 久久久久久久久蜜桃| 欧美国产日韩a欧美在线观看| 日本一区二区三区电影| 亚洲国产高清在线| 亚洲欧洲精品成人久久奇米网| 成人丝袜高跟foot| 国产成人av自拍| 97国产精品videossex| 欧美最猛性xxxxx直播| 51精品国自产在线| 26uuuu精品一区二区| 国产精品私房写真福利视频| 亚洲伦理在线精品| 丝袜美腿一区二区三区| 国产在线视频精品一区| eeuss鲁片一区二区三区在线看| 91丨九色丨蝌蚪富婆spa| 在线观看亚洲一区| 欧美一级日韩一级| 国产色91在线| 夜夜嗨av一区二区三区四季av| 午夜久久福利影院| 国产中文字幕精品| 在线免费观看成人短视频| 欧美一区二区三级| 欧美激情一区三区| 亚洲.国产.中文慕字在线| 九一久久久久久| 99久久精品免费看| 日韩一级二级三级| 国产精品美女久久久久高潮| 亚洲成人综合视频| 懂色一区二区三区免费观看| 欧美色欧美亚洲另类二区| 久久日韩粉嫩一区二区三区 | 日韩国产高清影视| 成人小视频免费在线观看| 欧美日韩专区在线| 久久精品人人做人人爽97| 亚洲国产综合色| 国产一区二区0| 欧美日韩国产高清一区| 国产精品久久久久精k8| 美女看a上一区| 色综合久久久久综合| 欧美va日韩va| 亚洲国产精品久久久男人的天堂| 国产成人精品午夜视频免费| 欧美日韩视频不卡| 18涩涩午夜精品.www| 九九国产精品视频| 欧美色图在线观看| 国产精品久久久久四虎| 久久精品国产色蜜蜜麻豆| 色成年激情久久综合| 亚洲精品一区二区三区蜜桃下载 | 日韩一区二区免费在线电影| 亚洲视频免费在线观看| 精品一区二区三区免费毛片爱| 91麻豆123| 日本一区二区三区久久久久久久久不 | 中文字幕一区视频| 美女国产一区二区三区| 日本韩国精品一区二区在线观看| 久久众筹精品私拍模特| 日韩精品午夜视频| 色素色在线综合| 国产精品久久综合| 国产高清不卡一区| 精品国产三级a在线观看| 亚洲成人tv网| 欧美熟乱第一页| 亚洲美女区一区| 成人午夜短视频| 欧美激情在线一区二区| 国产在线不卡一卡二卡三卡四卡| 91精品国产高清一区二区三区 | 蜜桃一区二区三区在线| 欧美视频一区在线观看| 中文字幕一区二区三区精华液 | 日本v片在线高清不卡在线观看| 91捆绑美女网站| 国产精品国产三级国产普通话三级| 国产在线不卡视频| 久久先锋影音av| 狠狠色2019综合网| 久久色成人在线| 国产一区在线不卡| 久久蜜桃一区二区| 国产成+人+日韩+欧美+亚洲| 国产午夜精品久久| 成人午夜激情片| 国产精品欧美一区二区三区| 成人白浆超碰人人人人| 国产精品拍天天在线| 99久久婷婷国产综合精品电影| 中文字幕亚洲欧美在线不卡| 成人免费电影视频| 国产精品久久久久三级| 91免费视频网| 一区二区三区久久| 欧美日韩成人一区| 久久国产日韩欧美精品| 久久在线观看免费| 成人综合婷婷国产精品久久免费| 中文字幕久久午夜不卡| 不卡的av电影| 亚洲精品国产视频| 欧美日韩国产美女| 玖玖九九国产精品| 欧美激情中文字幕一区二区| 97精品久久久午夜一区二区三区| 樱花影视一区二区| 91麻豆精品国产91久久久久久久久| 七七婷婷婷婷精品国产| 精品国产凹凸成av人网站| 成人午夜视频在线| 亚洲精品成人a在线观看| 欧美精品在线视频| 国产在线看一区| 中文字幕在线观看不卡视频| 在线看日韩精品电影| 日韩av电影免费观看高清完整版| 精品播放一区二区| 91啦中文在线观看| 麻豆91在线观看| 国产精品午夜免费| 欧美日韩国产综合视频在线观看| 精品一区二区三区视频| 亚洲欧美日韩人成在线播放| 丝袜亚洲另类欧美| 久久久久久影视| aaa欧美日韩| 日韩影院在线观看| 国产女人18毛片水真多成人如厕 | 欧美色图激情小说| 久久99精品国产麻豆婷婷洗澡| 国产精品视频九色porn| 欧美三级电影网站| 粉嫩欧美一区二区三区高清影视| 亚洲国产日韩综合久久精品| 久久精品在线观看| 欧美日韩一二三区| 国产91精品精华液一区二区三区| 午夜欧美视频在线观看| 中文字幕成人在线观看| 欧美丰满高潮xxxx喷水动漫| 99在线精品一区二区三区| 热久久国产精品| 一区二区三区在线不卡| 久久综合资源网| 欧美艳星brazzers| 成人教育av在线| 九九九精品视频| 日韩在线观看一区二区| 亚洲人成精品久久久久久| 久久综合久久综合久久| 欧美日韩国产精品成人| 91视频www| 成人网页在线观看| 经典三级视频一区| 亚洲va天堂va国产va久| 亚洲另类一区二区| 中文字幕不卡在线| 久久蜜桃一区二区| 日韩欧美中文字幕制服| 欧美日韩精品免费| 91免费观看视频| 不卡视频一二三四| 加勒比av一区二区| 日韩精品免费专区| 亚洲愉拍自拍另类高清精品| 中文字幕亚洲不卡| 国产午夜亚洲精品午夜鲁丝片| 91精品中文字幕一区二区三区| 色婷婷精品大在线视频 | 久久亚区不卡日本| 欧美丰满一区二区免费视频 | 国产精品你懂的| 久久久国产精品不卡| 欧美一级片在线| 欧美一区二区三区免费在线看 | 中文字幕中文乱码欧美一区二区| 欧美精品一区二区三区一线天视频 | 一本久久a久久免费精品不卡| 成人小视频在线观看| 国产成人在线视频网站|