This page describes how to use classes such as schema::Distribution to denote stochastic quantities, as a bridge between loading a scenario specification and populating the corresponding symbolic::Expression quantities into a systems::System.
We'll explain uses of schema::Distribution and related types using the matching YAML syntax as parsed by yaml::LoadYamlFile.
Given this C++ data structure:
You might load a YAML file such as this:
The stuff.value
is set to a constant (not stochastic) value 1.0.
Alternatively, you might load a YAML file such as this:
Now, stuff.value
is set to gaussian variable with the given mean and standard deviation.
The exclamation point syntax is a YAML type tag, which we use to specify the type choice within an std::variant
. The schema::DistributionVariant is a typedef for a specific std::variant
.
There are a few other choices for the type.
Here, you might specify a real-valued uniform range:
Or, you might choose from a set of equally-likely options:
You may also use YAML's flow style to fit everything onto a single line. These one-line spellings are the equivalent to those above.
For convenience, we also provide the option to specify a vector of independent stochastic variables with the same type.
We'll explain uses of schema::DistributionVector and related types using the matching YAML syntax as parsed by yaml::LoadYamlFile.
Given this C++ data structure:
You might load a YAML file such as this:
The thing.value
is set to a constant (not stochastic) vector with three elements.
You might also choose to constrain the vector to be a fixed size:
Whether fixed or dynamic size, you might specify stochastic variables:
Or:
Or:
All distributions still support constants for some elements and stochastic for others by specifying a zero-sized range for the constant elements:
Or:
See Configuring transforms for one practical application, of specifying rotations, translations, and transforms using stochastic schemas.