⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lhspoint.m

📁 遗传算法工具包
💻 M
字号:
function x = lhspoint(n,p)
%LHSPOINT Generates latin hypercube points.
%  	X = LHSPOINT(N,P) Generates a latin hypercube sample X containing N
%  	values on each of P variables.  For each column, the N values are
% 	 randomly distributed with one from each interval (0,1/N), (1/N,2/N),
% 	 ..., (N-1/N,1), and they are randomly permuted.

%   Copyright 2004 The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 2004/01/16 16:52:05 $

x = rand(n,p);
for i=1:p
    x(:,i) = rank(x(:,i));
end
x = x - rand(size(x));
x = x / n;
x = x';
%Safegaurd which should not occur in LHS
x(:,(~any(x))) = [];

%------------RANK function used by lhspoint
function r=rank(x)
[sx, rowidx] = sort(x);
r(rowidx) = 1:length(x);
r = r(:);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -