os2ref.m

来自「Optimized scaling算法 可以用来优化选择」· M 代码 · 共 50 行

M
50
字号
function[RMSEC,RMSEP]=os2ref(Xcal,ycal,Xval,yval);% [RMSEC,RMSEP]=os2ref(Xcal,ycal,Xval,yval);% % Optimized scaling 2, T. V. Karstang, R. Manne, Chemolab 14 (1992) 165-173% y=(x*b)./(x*c), b-regression coefficient, c-scaling coefficient% % Testing through all the objects for detection of best reference. RMSEC/RMSEP values for every score is obtained.% Use bar(RMSEC) and bar(RMSEP)% Xcal: scores for calibration set: [T,P]=apca(X), % Xval: scores for val.set: Tv=X*P% % L. Stordrange 02.03.01, Uppdated 27.06.01[i,j]=size(Xcal);[v,w]=size(Xval);RMSEC=zeros(i,j);RMSEP=zeros(i,j);for t=1:j   for k=1:i      xnull=Xcal(k,1:t);       ynull=ycal(k);      Z=diag(ycal)*Xcal(:,1:t);      Z(k,:)=zeros(1,t);      ZX=[Z Xcal(:,1:t)];      xnull0=[xnull,zeros(1,t)];            % The final system of linear equations is denoted A*p=q      A=[ZX'*ZX,xnull0';xnull0,0];      q=[zeros(t,1);-ynull*xnull';1];      p=A\q; %             c=p(1:t);      b=-p(t+1:2*t);      %lamda=-p(2*j+1);            yc=(Xcal(:,1:t)*b)./(Xcal(:,1:t)*c);      ec=yc-ycal;      RMSEC(k,t)=sqrt((ec'*ec)/i);            yv=(Xval(:,1:t)*b)./(Xval(:,1:t)*c);      ev=yv-yval;      RMSEP(k,t)=sqrt((ev'*ev)/v);   endend

⌨️ 快捷键说明

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