【发布时间】:2014-03-06 15:32:15
【问题描述】:
有没有办法从一组特定的数据创建拉丁超立方体?我有d(1,:) = 3*t +0.00167*randn(1,1000);。有没有办法让我从d(1,:) 中的元素创建一个拉丁超立方体?
非常感谢
【问题讨论】:
有没有办法从一组特定的数据创建拉丁超立方体?我有d(1,:) = 3*t +0.00167*randn(1,1000);。有没有办法让我从d(1,:) 中的元素创建一个拉丁超立方体?
非常感谢
【问题讨论】:
lhsnorm 函数的编辑可能会回答您的问题。
在 matlab 中:edit lhsnorm:
function [X,z] = lhsnorm(mu,sigma,n,dosmooth)
%LHSNORM Generate a latin hypercube sample with a normal distribution
% X=LHSNORM(MU,SIGMA,N) generates a latin hypercube sample X of size
% N from the multivariate normal distribution with mean vector MU
% and covariance matrix SIGMA. X is similar to a random sample from
% the multivariate normal distribution, but the marginal distribution
% of each column is adjusted so that its sample marginal distribution
% is close to its theoretical normal distribution.
%
% X=LHSNORM(MU,SIGMA,N,'ONOFF') controls the amount of smoothing in the
% sample. If 'ONOFF' is 'off', each column has points equally spaced
% on the probability scale. In other words, each column is a permutation
% of the values G(.5/N), G(1.5/N), ..., G(1-.5/N) where G is the inverse
% normal cumulative distribution for that column''s marginal distribution.
% If 'ONOFF' is 'on' (the default), each column has points uniformly
% distributed on the probability scale. For example, in place of
% 0.5/N we use a value having a uniform distribution on the
% interval (0/N,1/N).
%
% [X,Z]=LHSNORM(...) also returns Z, the original multivariate normal
% sample before the marginals are adjusted to obtain X.
%
% See also LHSDESIGN, MVNRND.
% Reference: Stein, M. L. (1987). Large sample properties of simulations
% using Latin hypercube sampling. Technometrics, 29, 143-151. Correction,
% 32, 367.
% Copyright 1993-2010 The MathWorks, Inc.
% $Revision: 1.1.8.1 $ $Date: 2010/03/16 00:15:10 $
% Generate a random sample with a specified distribution and
% correlation structure -- in this case multivariate normal
z = mvnrnd(mu,sigma,n);
% Find the ranks of each column
p = length(mu);
x = zeros(size(z),class(z));
for i=1:p
x(:,i) = rank(z(:,i));
end
% Get gridded or smoothed-out values on the unit interval
if (nargin<4) || isequal(dosmooth,'on')
x = x - rand(size(x));
else
x = x - 0.5;
end
x = x / n;
% Transform each column back to the desired marginal distribution,
% maintaining the ranks (and therefore rank correlations) from the
% original random sample
for i=1:p
x(:,i) = norminv(x(:,i),mu(i), sqrt(sigma(i,i)));
end
X = x;
% -----------------------
function r=rank(x)
% Similar to tiedrank, but no adjustment for ties here
[sx, rowidx] = sort(x);
r(rowidx) = 1:length(x);
r = r(:);
在您的情况下,您在上面的代码中已经有了您的发行版z,并且您还有mu、sigma 和“n”(您的发行版的大小),只需替换它们,您应该能够创建你的拉丁超立方体。
【讨论】:
lhsnorm(3*t, 0.00167 ,1000); 给我一个来自正态分布的拉丁超立方体样本。但是,如果我已经有一组正态分布的数据,例如我上面提到的d(1,:) 中的数据,并且我想从中采样,我不知道如何编辑lhsnorm。
function [X] = lhsnorm_sid(z,dosmooth) [muhat,sigmahat] = normfit(z); z = z'; % Find the ranks of each column p = length(muhat); x = zeros(size(z),class(z)); s = size(z); n = s(1,1);
lhsnorm(3*60/800,0.00167,1000) 并更改 z 我仍然遇到输出问题