API Reference

Design of Experiment API

Design of Experiment API

UQPyL.doe

The doe module generates design samples from a Problem input space. Samplers first generate samples in unit space, then map them to the problem bounds through problem.unit_to_space().

Import

python
from UQPyL.doe import LHS, Random, FFD, Sobol

Public Objects

ObjectRole
SamplerBase class for DOE samplers.
RandomUniform random sampling.
LHSLatin hypercube sampling.
FFDFull factorial design.
SobolSobol low-discrepancy sequence sampling.
SaltelliDesignSaltelli design for Sobol sensitivity analysis.
FASTDesignFAST design for sensitivity analysis.
MorrisDesignMorris trajectory design for sensitivity analysis.

Sampler

Sampler is the base interface used by most DOE classes.

Methods

MethodReturnsMeaning
sample(problem, nSamples=None, seed=None, nt=None)np.ndarrayGenerate samples in the problem space.
sampleWithMeta(problem, nSamples=None, seed=None, nt=None)(np.ndarray, dict)Generate samples and metadata.
ParameterMeaning
problemA ProblemBase instance, such as Problem, ModelProblem, or a benchmark problem.
nSamplesNumber of samples or base sample size, depending on the sampler.
seedOptional random seed.
ntLegacy alias for nSamples. If both are provided, they must match.

Example:

python
from UQPyL.doe import LHS
from UQPyL.problem import Sphere


problem = Sphere(nInput=3)
sampler = LHS()

X = sampler.sample(problem, nSamples=10, seed=123)
print(X.shape)

Use sampleWithMeta() when downstream methods need design metadata:

python
X, meta = sampler.sampleWithMeta(problem, nSamples=10, seed=123)

print(meta["designType"])

Random

Uniform random sampler.

python
Random()
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate random samples in the problem space.
sampleWithMeta(problem, nSamples=None, seed=None, nt=None)Generate random samples with metadata.

Metadata:

KeyMeaning
designTypeAlways "random".
seedSeed used to initialize the random generator.

LHS

Latin hypercube sampler.

python
LHS(criterion="classic", iterations=5)
ParameterMeaning
criterionLHS criterion. One of "classic", "center", "maximin", "center_maximin", or "correlation".
iterationsNumber of candidate designs tested by optimized criteria.
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate LHS samples in the problem space.
sampleWithMeta(problem, nSamples=None, seed=None, nt=None)Generate LHS samples with metadata.

Metadata:

KeyMeaning
designTypeAlways "lhs".
criterionCriterion used by the sampler.
iterationsIteration count for optimized criteria.
seedSeed used to initialize the random generator.

Example:

python
from UQPyL.doe import LHS
from UQPyL.problem import Sphere


problem = Sphere(nInput=2)
sampler = LHS(criterion="maximin", iterations=10)

X, meta = sampler.sampleWithMeta(problem, nSamples=20, seed=123)
print(X.shape)
print(meta["criterion"])

FFD

Full factorial design.

python
FFD()

Unlike most samplers, FFD uses levels instead of nSamples.

MethodReturnsMeaning
sample(problem, levels, seed=None)np.ndarrayGenerate the full factorial grid in the problem space.
sampleWithMeta(problem, levels, seed=None)(np.ndarray, dict)Generate the grid with metadata.
ParameterMeaning
levelsScalar level count applied to all variables, or one level count per variable.
seedAccepted for API consistency. It does not affect the deterministic grid.

Metadata:

KeyMeaning
designTypeAlways "full_fact".
levelsLevel count used for each variable.
seedAlways None.

Example:

python
from UQPyL.doe import FFD
from UQPyL.problem import Sphere


problem = Sphere(nInput=2)
sampler = FFD()

X, meta = sampler.sampleWithMeta(problem, levels=[3, 4])
print(X.shape)
print(meta["levels"])

Sobol

Sobol low-discrepancy sequence sampler.

python
Sobol(scramble=True, skipValue=0)
ParameterMeaning
scrambleWhether to scramble the Sobol sequence.
skipValueNumber of initial Sobol points to skip.
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate Sobol samples in the problem space.
sampleWithMeta(problem, nSamples, seed=None)Generate Sobol samples with metadata.

Metadata:

KeyMeaning
designTypeAlways "sobol_sequence".
scrambleWhether scrambling was enabled.
skipValueNumber of skipped initial points.
seedSeed used when scramble=True; otherwise None.

nSamples should usually be a power of 2 for balanced Sobol samples. skipValue must be a non-negative integer and cannot exceed nSamples.

SaltelliDesign

Saltelli design for Sobol sensitivity analysis.

python
SaltelliDesign(scramble=True, skipValue=0, secondOrder=False)
ParameterMeaning
scrambleWhether to scramble the Sobol base sequence.
skipValueNumber of initial Sobol points to skip.
secondOrderWhether to generate the second-order design.
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate the design in the problem space.
sampleWithMeta(problem, N, seed=None)Generate the design with metadata.

For a problem with D inputs and base sample size N, output shape is:

secondOrderShape
False((D + 2) * N, D)
True((2 * D + 2) * N, D)

Metadata:

KeyMeaning
designTypeAlways "saltelli".
NBase sample size.
secondOrderWhether second-order design was generated.
skipValueNumber of skipped Sobol points.
scrambleWhether scrambling was enabled.
blockSizeNumber of rows per base sample.
seedSeed used when scramble=True; otherwise None.

N should usually be a power of 2. skipValue must be a non-negative integer and cannot exceed N.

FASTDesign

FAST design for sensitivity analysis.

python
FASTDesign(M=4)
ParameterMeaning
MFAST interference parameter. Must be a positive integer.
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate the FAST design in the problem space.
sampleWithMeta(problem, N, seed=None)Generate the FAST design with metadata.

For a problem with D inputs and base sample size N, output shape is:

text
(N * D, D)

N must satisfy:

text
N > 4 * M^2

Metadata:

KeyMeaning
designTypeAlways "fast".
NBase sample size.
MFAST interference parameter.
blockSizeRows per input variable.
seedSeed used to initialize the random generator.

MorrisDesign

Morris trajectory design for sensitivity analysis.

python
MorrisDesign(numLevels=4)
ParameterMeaning
numLevelsNumber of Morris levels. Must be an even integer greater than or equal to 4.
MethodMeaning
sample(problem, nSamples=None, seed=None, nt=None)Generate Morris trajectories in the problem space.
sampleWithMeta(problem, numTrajectory, seed=None)Generate Morris trajectories with metadata.

For a problem with D inputs and numTrajectory trajectories, output shape is:

text
(numTrajectory * (D + 1), D)

Metadata:

KeyMeaning
designTypeAlways "morris".
numTrajectoryNumber of trajectories.
numLevelsNumber of Morris levels.
trajectorySizeRows per trajectory, equal to D + 1.
seedSeed used to initialize the random generator.

Example:

python
from UQPyL.doe import MorrisDesign
from UQPyL.problem import Sphere


problem = Sphere(nInput=3)
sampler = MorrisDesign(numLevels=4)

X, meta = sampler.sampleWithMeta(problem, numTrajectory=10, seed=21)
print(X.shape)
print(meta["trajectorySize"])