lhsdesign
Latin hypercube sample
Description
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'
.
Examples
Create Latin Hypercube Sample
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]
.
Latin Hypercube Design with Nondefault Options
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).
Input Arguments
n
— Number of returned samples
positive integer
Number of returned samples, specified as a positive integer.
Example: 24
Data Types: single
| double
p
— Number of returned variables
positive integer
Number of returned variables, specified as a positive integer.
Example: 4
Data Types: single
| double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 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 criterion
5
(default) | positive integer
Maximum 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
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)