对LHS介绍的可以参考:https://blog.csdn.net/Together_CZ/article/details/90076271
下面是4种分布的matlab程序,包含正态分布,均匀分布, 对数正态分布,extreme type 1。
1.对正态(超级的小海豚)分布的变量进行拉丁超立方采样
参考:https://blog.csdn.net/chichuhe/article/details/89890720#commentsedit
原文还有均匀分布的LHS采样程序。
2.对数正态分布的LHS采样
clc;close all; clearvars;% 对数正态分布的参数设置 m=20;dist=[3,3];mu=[3.6e7,1.98e8];sigma=[3.6e6,9.9e6];lowb=[mu-3*sigma];upb=[mu+3*sigma];n=length(mu);if length(dist)~=n|length(sigma)~=n|length(lowb)~=n|length(upb)~=n error('dist,mu,sigma,lowb,upb must have the same length');endrvcom=[];for j=1:n rv=[];if dist(j)==3 %对数正态分布 p_low(j)=logncdf(lowb(j),mu(j),sigma(j)); p_up(j)=logncdf(upb(j),mu(j),sigma(j)); p_bound(j)=p_up(j)-p_low(j); p_subbound(j)=p_bound(j)./(m-1); for i=0:m-1 rv=[rv;logninv(p_low(j)+i.*p_subbound(j),mu(j),sigma(j))]; endelseif dist(j)==4 %for extreme type 1 p_low(j)=evcdf(lowb(j),mu(j),sigma(j)); p_up(j)=evcdf(upb(j),mu(j),sigma(j)); p_bound(j)=p_up(j)-p_low(j); p_subbound(j)=p_bound(j)./(m-1); for i=0:m-1 rv=[rv;evinv(p_low(j)+i.*p_subbound(j),mu(j),sigma(j))]; endendrvcom=[rvcom rv];endS=[];for i=1:n S=[S randsample(rvcom(:,i),m)];endif n==2 figure plot(S(:,1),S(:,2),'r*');grid on title('对数正态分布的LHS采样')elseif n==3 figure plot3(S(:,1),S(:,2),S(:,3),'lc.');grid onend将上述程序中的distvia变量参数改为4即是extreme type 1分布的LHS采样。
有问题欢迎交流哈~