1 Star 0 Fork 0

Admin/marx_DisPAT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lhs_iman_n.m 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
marx 提交于 2021-11-26 19:53 . v1
function z=lhs_iman_n(xmean,xsd,corr)
% z=lhs_iman_n(xmean,xsd,corr,nsample,ntry)
% LHS with correlation, normal distribution
% Method of Iman & Conover
% 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)
% Budiman (2004)
% using mchol from Brian Borchers
nvar=length(xmean);
if(nargin==4), ntry=1; end;
% induce data with correlation
[L,D,E]=mchol(corr);
%P = chol(corr+E)';
P=L*sqrt(D);
xm=zeros(1,nvar);
xs=ones(1,nvar);
R=latin_hs(xm,xs,1,nvar);
T = corrcoef(R);
[L,D,E]=mchol(T);
%Q=chol(T+E)';
Q=L*sqrt(D);
S = P * inv(Q);
RB= R*S';
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/marx_1_1307066363/marx_-dis-pat.git
git@gitee.com:marx_1_1307066363/marx_-dis-pat.git
marx_1_1307066363
marx_-dis-pat
marx_DisPAT
master

搜索帮助