lhs_iman_n - % Budiman (2004) % using mchol from Brian...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function z=lhs_iman_n(xmean,xsd,corr,nsample,ntry) % z=lhs_iman_n(xmean,xsd,corr,nsample,ntry) % LHS with correlation, normal distribution % using mchol for Cholesky decomposition so that corr. matrix is positive definite % % Iman, R. L., and W. J. Conover. 1982. A Distribution-free Approach to Inducing Rank Correlation % Among Input Variables. Communications in Statistics B 11:311-334 % % Input: % xmean : mean of data (1,nvar) % xsd : std.dev of data (1,nvar) % corr : correlation matrix of the variables (nvar,nvar) % nsample : no. of samples % ntry : optional, no of trial to get a close correlation matrix % Output: % z : random sample (nsample,nvar)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Budiman (2004) % using mchol from Brian Borchers nvar=length(xmean); n if(nargin==4), ntry=1; end; i % induce data with correlation [L,D,E]=mchol(corr); %P = chol(corr+E)'; P=L*sqrt(D); P xm=zeros(1,nvar); xs=ones(1,nvar); R=latin_hs(xm,xs,nsample,nvar); T = corrcoef(R); [L,D,E]=mchol(T); %Q=chol(T+E)'; Q=L*sqrt(D); S = P * inv(Q); RB= R*S'; R amin=realmax; for il=1:ntry for j=1:nvar % rank RB [r,id]=ranking(RB(:,j)); % sort R [RS,id]=sort(R(:,j)); % permute RS so has the same rank as RB z(:,j) = RS(r).*xsd(j)+xmean(j); end ae=sum(sum(abs(corrcoef(z)-corr))); if(ae<amin), zb=z; amin=ae; end; end e z=zb;...
View Full Document

Ask a homework question - tutors are online