Latin hypercube sample
modifies the resulting design using one or more name-value pair arguments. For
example, you can obtain a discrete design by specifying
X
= lhsdesign(n
,p
,Name,Value
)'Smooth','off'
.
Create a Latin hypercube sample of 10 rows and 4 columns.
rng default % For reproducibility X = lhsdesign(10,4)
X = 10×4
0.1893 0.2569 0.0147 0.5583
0.8038 0.1089 0.9378 0.1950
0.5995 0.6818 0.3649 0.3097
0.3225 0.8736 0.4487 0.8055
0.9183 0.9854 0.1598 0.2509
0.0131 0.3864 0.5924 0.7511
0.7916 0.7131 0.2760 0.6662
0.6600 0.5420 0.6877 0.9100
0.2740 0.0450 0.7816 0.0631
0.4200 0.4855 0.8760 0.4889
Each column of X
contains one random number in each interval [0,0.1]
, [0.1,0.2]
, [0.2,0.3]
, [0.3,0.4]
, [0.4,0.5]
, [0.5,0.6]
, [0.6,0.7]
, [0.7,0.8]
, [0.8,0.9]
, and [0.9,1]
.
Determine the effects of various name-value pair arguments in lhsdesign
. Start with a default design for 10 rows and four columns.
rng default % For reproducibility X = lhsdesign(10,4)
X = 10×4
0.1893 0.2569 0.0147 0.5583
0.8038 0.1089 0.9378 0.1950
0.5995 0.6818 0.3649 0.3097
0.3225 0.8736 0.4487 0.8055
0.9183 0.9854 0.1598 0.2509
0.0131 0.3864 0.5924 0.7511
0.7916 0.7131 0.2760 0.6662
0.6600 0.5420 0.6877 0.9100
0.2740 0.0450 0.7816 0.0631
0.4200 0.4855 0.8760 0.4889
To obtain a discrete design. as opposed to a continuous design, set the 'Smooth'
name-value pair argument to 'off'
.
rng default % For reproducibility X = lhsdesign(10,4,'Smooth','off')
X = 10×4
0.2500 0.3500 0.7500 0.8500
0.1500 0.8500 0.2500 0.3500
0.8500 0.7500 0.4500 0.7500
0.9500 0.1500 0.6500 0.1500
0.0500 0.0500 0.8500 0.9500
0.4500 0.5500 0.9500 0.4500
0.3500 0.9500 0.5500 0.0500
0.5500 0.4500 0.0500 0.2500
0.6500 0.6500 0.1500 0.6500
0.7500 0.2500 0.3500 0.5500
The resulting design is discrete.
Calculate the sum of squares of the between-column correlations of the returned design.
y = corr(X);
(sum(y(:).^2) - 4)/2 % Subtract 4 to remove the diagonal terms of corr(X)
ans = 0.4874
Observe the effect of changing the 'Criterion'
name-value pair argument to 'correlation'
, which minimizes the sum of between-column squared correlations. The 'correlation'
criterion always gives a discrete design, as if 'Smooth'
is set to 'off'
.
rng default % For reproducibility X = lhsdesign(10,4,'Criterion','correlation')
X = 10×4
0.6500 0.0500 0.4500 0.7500
0.2500 0.3500 0.0500 0.1500
0.1500 0.9500 0.8500 0.4500
0.8500 0.5500 0.9500 0.0500
0.5500 0.2500 0.5500 0.3500
0.3500 0.4500 0.7500 0.8500
0.4500 0.1500 0.6500 0.6500
0.0500 0.6500 0.2500 0.5500
0.9500 0.8500 0.3500 0.9500
0.7500 0.7500 0.1500 0.2500
y = corr(X); (sum(y(:).^2) - 4)/2
ans = 0.0102
Minimizing the correlations results in a design with much lower sum of squared correlations.
Specify fewer iterations to improve the criterion.
rng default % For reproducibility X = lhsdesign(10,4,'Criterion','correlation','Iterations',2)
X = 10×4
0.6500 0.0500 0.4500 0.7500
0.3500 0.3500 0.0500 0.1500
0.1500 0.9500 0.8500 0.4500
0.9500 0.5500 0.9500 0.0500
0.5500 0.2500 0.5500 0.3500
0.2500 0.4500 0.7500 0.8500
0.4500 0.1500 0.6500 0.6500
0.0500 0.6500 0.2500 0.5500
0.8500 0.8500 0.3500 0.9500
0.7500 0.7500 0.1500 0.2500
y = corr(X); (sum(y(:).^2) - 4)/2
ans = 0.0328
Lowering the number of iterations results in a worse design (higher sum of squared correlations).
n
— Number of returned samplesNumber of returned samples, specified as a positive integer.
Example: 24
Data Types: single
| double
p
— Number of returned variablesNumber of returned variables, specified as a positive integer.
Example: 4
Data Types: single
| double
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
X = lhsdesign(n,p,'Smooth','off')
returns a discrete
Latin hypercube design'Smooth'
— Indication for continuous samples'on'
(default) | 'off'
Indication for continuous samples, specified as the comma-separated
pair consisting of 'Smooth'
and
'on'
(continuous samples) or
'off'
(discrete samples). When this option is
'off'
, the returned values in each column of
X
are a random permutation of the values
0.5/n
, 1.5/n
, …, 1 –
0.5/n
.
Example: 'Smooth','off'
Data Types: char
| string
'Criterion'
— Criterion for iterative sample generation'maximin'
(default) | 'none'
| 'correlation'
Criterion for iterative sample generation, specified as the
comma-separated pair consisting of 'Criterion'
and
'maximin'
, 'none'
, or
'correlation'
. The algorithm uses up to
Iterations
tries to improve the
criterion.
Note
The 'correlation'
criterion gives discrete
samples, as if Smooth
is set to
'off'
.
Criterion | Description |
---|---|
| Maximize the minimum distance between points. |
| Minimize the sum of between-column squared correlations. |
| No iteration |
Example: 'Criterion','correlation'
Data Types: char
| string
'Iterations'
— Maximum number of iterations to improve criterion5
(default) | positive integerMaximum number of iterations to improve
Criterion
, specified as the comma-separated pair
consisting of 'Iterations'
and a positive integer.
The algorithm uses up to Iterations
tries to
improve the criterion.
Example: 'Iterations',10
Data Types: single
| double
You have a modified version of this example. Do you want to open this example with your edits?