sdo.sample

Generate parameter samples

Syntax

Description

example

x = sdo.sample(ps) generates samples using the specified parameter space definition, ps. The output sample table, x, has 2Np+1 rows and Np columns. Each column corresponds to a parameter and each row corresponds to a sample of the parameters. Np is the number of parameters in ps. The samples are generated as per the ParameterDistributions, RankCorrelation, and Options property of ps.

example

x = sdo.sample(ps,N) specifies the number of samples to be generated. x is a table with N rows and Np columns.

example

x = sdo.sample(___,opt) specifies sampling options such as the sampling method. This syntax can include any of the input argument combinations in the previous syntaxes.

Examples

expand all

Generate Parameter Samples

Generate samples for the Ac and K parameters of the sdoHydraulicCylinder model.

Open the model.

open_system('sdoHydraulicCylinder');

Obtain the parameters from the model.

p = sdo.getParameterFromModel('sdoHydraulicCylinder',{'Ac','K'});

Create an sdo.ParameterSpace object to specify the sample distributions.

ps = sdo.ParameterSpace(p);

Generate samples for the parameters.

x = sdo.sample(ps);

Specify Number of Samples

Generate 50 samples for the Ac and K parameters of the sdoHydraulicCylinder model.

Open the model.

open_system('sdoHydraulicCylinder');

Obtain the parameters from the model.

p = sdo.getParameterFromModel('sdoHydraulicCylinder',{'Ac','K'});

Create an sdo.ParameterSpace object to specify the sample distributions.

ps = sdo.ParameterSpace(p);

Generate 50 samples for the parameters.

x = sdo.sample(ps,50);

Specify Sampling Options

Open the model.

open_system('sdoHydraulicCylinder');

Obtain the parameters from the model.

p = sdo.getParameterFromModel('sdoHydraulicCylinder',{'Ac','K'});

Create an sdo.ParameterSpace object to specify the sample distributions.

ps = sdo.ParameterSpace(p);

Specify the sampling method used by the software.

opt = sdo.SampleOptions;
opt.Method = 'lhs';

The 'lhs' (Latin hypercube) sampling method requires a Statistics Toolbox™ license.

Generate 50 samples for the parameters using Latin hypercube sampling.

x = sdo.sample(ps,50,opt);

Input Arguments

expand all

ps — Parameter space distributionsdo.ParameterSpace object

Parameter space distribution definition, specified as an sdo.ParameterSpace object.

N — Number of samplespositive integer

Number of samples to be generated for the parameters, specified as a positive integer.

Ideally, you want to use the smallest number of samples that yield useful results, because each sample requires a model evaluation.

As the number of parameters increases, the number of samples needed to explore the design space generally increases. For correlation or regression analysis, consider using 10Np samples, where Np is the number of parameters.

Example: 10

opt — Sampling optionssdo.SampleOptions object

Sampling options, specified as an sdo.SampleOptions object.

Output Arguments

expand all

x — Parameter samplestable

Parameter samples, returned as a table.

x has Ns rows and Np columns. Each column corresponds to a parameter and each row corresponds to a sample of the parameters. Np is the number of parameters in ps. If you specify N, Ns is equal to N. Otherwise, Ns is equal to 2Np+1.

Was this topic helpful?