Augmenting Latin Hypercube Points in MATLAB -
i know commands create lhs design , augment more points later on if model not enough? example, first create 50 points lhs design, add more points (perhaps in batches of 20) incrementally until model accurate enough. example:
set1=lhsdesign(5,5); %5x5 matrix %use of set 1, determine more points needed set2=%some command adds 20 points set1 make 25x5 matrix
the difficulty in running lhsdesign again 20 new points not take account of original points. there work done using original points , generating new set of points scratch wastes work new points not included in new set.
i able make function solves problem. not sure final matrix true latin hypercube, adds required number of points given points , moves them closest available open 'channel' (sub range no point exists) if need be.
usage follows:
x1=lhsdesign(200,17); xf=lhsaugment(x1,200);
which adds 200 points x1 set of points, resulting in xf being 400x17 matrix. function follows:
function xf = lhsaugment(x1,npoi) %function xf = lhsaugment(x1,npoi) %function augment given latin hypercube x1 number of points, %npoi. length changed, i.e. points added length. %the original points left unctouched , appear first in output %xf. size of xf [size(x1,1)+npoi size(x1,2)]. x2=lhsdesign(npoi,size(x1,2)); npoi=size(x2,1); opoi=size(x1,1); tpoi=npoi+opoi; fint=1/tpoi; i=1:tpoi cbound(i,:)=[(i-1)*fint i*fint]; end xf=zeros(tpoi,size(x1,2)); bx1=zeros(size(x1)); bx2=zeros(size(x2)); bf=zeros(tpoi,size(x1,2)); if=zeros(1,size(x1,2)); imove=0; i=1:opoi j=1:size(cbound,1) l=1:size(x1,2) if (x1(i,l)>cbound(j,1))&&(x1(i,l)<=cbound(j,2))&&(bf(j,l)==0) if(1,l)=if(1,l)+1; xf(if(1,l),l)=x1(i,l); bx1(i,l)=1; bf(j,l)=1; elseif (x1(i,l)>cbound(j,1))&&(x1(i,l)<=cbound(j,2))&&(bf(j,l)~=0) imin=size(cbound,1); pmin=size(cbound,1); m=j:-1:1 if (bf(m,l)==0) imin=m; pmin=j-m; break end end m=j:size(cbound,1) if (bf(m,l)==0)&&(m-j<pmin) imin=m; pmin=j+m; break end end if(1,l)=if(1,l)+1; xf(if(1,l),l)=x1(i,l); bx1(i,l)=1; bf(imin,l)=1; end end end end i=1:npoi j=1:size(cbound,1) l=1:size(x2,2) if (x2(i,l)>cbound(j,1))&&(x2(i,l)<=cbound(j,2))&&(bf(j,l)==0) if(1,l)=if(1,l)+1; xf(if(1,l),l)=x2(i,l); bx2(i,l)=1; bf(j,l)=1; elseif (x2(i,l)>cbound(j,1))&&(x2(i,l)<=cbound(j,2))&&(bf(j,l)~=0) imin=size(cbound,1); pmin=size(cbound,1); m=j:-1:1 if (bf(m,l)==0) imin=m; pmin=j-m; break end end m=j:size(cbound,1) if (bf(m,l)==0)&&(m-j<pmin) imin=m; pmin=j+m; break end end if(1,l)=if(1,l)+1; xf(if(1,l),l)=(x2(i,l)-(floor(x2(i,l)/fint)*fint))+((imin-1)*fint); bx2(i,l)=1; bf(imin,l)=1; if l==1 imove=imove+1; end end end end end
Comments
Post a Comment