function [BTRAIN,CNTER]=replica(TNSPEC,B) % TNSPEC=training spectra, B=number of replicates desired. % REPLICA outputs BTRAIN replicates, and the center of the replicates in CNTER % % "Copyright 2003 Robert A. Lodder & Bin Dai" % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License % as published by the Free Software Foundation; either version 2 % of the License, or (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. % % Contact Information located at www.pharm.uky.edu or search the World Wide Web % for Analytical Spectroscopy Research Group. [N,D]=size(TNSPEC); BTRAIN=zeros(B,D); CNTER=zeros(D,1); BSAMP=zeros(N,D); PICKS=rand(B*N,1); index=find(PICKS==1); PICKS(index)=0.9999; PICKS=reshape(PICKS,B,N); PICKS=fix(N*PICKS+1); for I=1:B BSAMP=TNSPEC(PICKS(I,:),:); BTRAIN(I,:)=sum(BSAMP)/N; end BTRAIN; CNTER=sum(BTRAIN)/B;