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

📄 pls的迭代算法程序.txt

📁 kennard-stone选样本算法。。。PLS的迭代算法程序
💻 TXT
字号:
function [B,p,w,b]=pls1(x,y,A); 
%[p,w,b]=pls1(x,y,maxnum) is a program by using pls1 algorithm to build a PLS model. 
%x is a n*m matrix,where m is wavelength number and n sample number. 
%y is a n*1 vector.   
% A is a input parameter stated maximum of principle component number. 
%output p is loadings, w weights and b is the regression coefficient. 
% By Yiping Du, 2002,10,30, modeified in 2003,06,17  

%%%%%%%%%%%%%%%%%%  MAIN  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
[n,m]=size(x);[nc,mc]=size(y); 
if n~=nc;errordlg('error input of x and y','pls'); return;end; 
n_p=min([m,n,A]); 
t=[];p=[];b=[];w=[];resi_y=[];resi_x=[]; 
for i=1:n_p 
   t=y;%one column with n elements 
   w=t'*x/(t'*t);%one row with m elements, w is mid var. of p 
   w=w/norm(w,2);%norm(w,2)=sqrt(w*w') 
   t=x*w'/(w*w');% one column with n elements 
   p=t'*x/(t'*t);  
   b=y'*t/(t'*t);%b is actually the q in models usually used. 
   pp(i,:)=p;tt(:,i)=t; ww(i,:)=w;bb(i)=b; 
   x=x-t*p; 
   y=y-b*t;   
end; 
p=pp';w=ww';b=bb'; 
B=w(:,1:A)/(p(:,1:A)'*w(:,1:A))*b(1:A); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

⌨️ 快捷键说明

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