LHS拉丁超立方采样matlab程序,对于均匀分布与正态(高斯)分布的变量进行拉丁超立方采样

1、对正态(高斯)分布的变量进行拉丁超立方采样

clc
clear all
close all
cst_Mu_Sigma = load( 'cst_Mu_Sigma.dat');
Mu = cst_Mu_Sigma(:,1);
Sigma = cst_Mu_Sigma(:,2);
D = size(Mu,1); % 维数

Covariance_Matrix = zeros(D,D);
for i = 1:D
    Covariance_Matrix(i,i) = Sigma(i)^2;
end

N = 3000; % 样本点数目
UB = Mu + 3*Sigma;
LB = Mu - 3*Sigma; % 取值范围

X = lhsnorm(Mu, Covariance_Matrix, N);

figure(6)
plot(X(:,1),X(:,2),'*')

2、对均匀分布的变量进行拉丁超立方采样

clc
clear all
close all
cst_Mu_Sigma = load( 'cst_Mu_Sigma.dat');
Mu = cst_Mu_Sigma(:,1);
Sigma = cst_Mu_Sigma(:,2);

N = 3000; % 样本点数目
UB = Mu + 3*Sigma;
LB = Mu - 3*Sigma; % 取值范围
P = zeros(N,N); 
D = size(MU,1); % 维数
Num = 100;  % 重复次数


Lmax = 0;
for q = 1:Num
    
  for i = 1:D
    S(:, i) = ((randperm(N) -1 + rand(1, N)))' / N;
  end
  
  for i = 1:N
    for j = 1:N
      P(i,j) = sqrt((S(i,1)-S(j,1))^2 + (S(i,2)-S(j,2))^2);
    end
  end
  
  P(P == 0) = 1;
  m = min(P);
  mm = min(m);
  if mm>Lmax % mm越大越好,mm为二维矩阵P中的最小元素
    Lmax = mm;
    Sout = S;
  end
end

Sout = Sout*(UB - LB) + LB; % 样本点的取值
figure(6)
plot(Sout(:,1),Sout(:,2),'*')

 

你可能感兴趣的:(经验)