This section explains how to use a few additional functions that come packaged with *Scenarios*, including the command `ACTUAL`

. For additional explanation, contact Invrea here.

**Parameters:** At least two: first a datum, then a type of distribution in double quotes, and then the parameters of this distribution.

**Return Types:** All data types - returns the datum supplied as the first argument

**Description:** `ACTUAL`

is the *Scenarios* command that is used to train a model on true data. The first argument is the datum to be learned from, and the second argument is the type of distribution assumed for this data, in double quotes. The next arguments are the parameters of the distribution being used. For example, to observe that the value of the cell `B7`

is between 4 and 8, the following syntax should be used: `=ACTUAL(B7, "between", 4, 8)`

. In general, if `DISTRIBUTION(X, Y, Z)`

is any random variable, then observing that this random variable takes value D is simply `=ACTUAL(K, "DISTRIBUTION", X, Y, Z)`

. The construct `ACTUAL`

performs a function similar to the `observe`

and `factor`

keywords in probabilistic programming languages. For more information on using `ACTUAL`

, look here.

**Error Conditions:** The error conditions for `ACTUAL`

are determined by the error conditions for the corresponding distribution. For example, the standard deviation of the normal distribution must be positive. Therefore, `=GAUSSIAN(1, -1)`

, is invalid, and so `=ACTUAL(3, "gaussian", 1, -1)`

is also invalid.

(↩)

**Parameters:** Nine, all of which other than the first are optional. The first is a range of dependent variables `Y`

, the second is a range or array of independent variables `X`

, the third is a logical value determining whether linear regression is performed with or without a constant, the fourth is a logical value determining whether optional linear regression statistics are returned, the fifth and sixth are the shape and rate parameters respectively of the inverse-gamma prior, the seventh is a prior on the mean weights (a range or array), the eighth is a prior on the covariance matrix (a range or array), and the ninth is a model ID, an integer.

**Return Type:** A matrix, whose composition depends on whether statistics are enabled and/or a constant is encluded. See LINEST help for a description of what elements are where - `LINEST`

and `BAYESLINEST`

have the same form of outputs, although `BAYESLINEST`

takes additional arguments.

**Description:** `BAYESLINEST`

performs Bayesian linear regression from the input matrix `X`

to the output vector `Y`

using a standard normal-inverse-gamma model, generating a distribution over possible weights and possible statistics. `BAYESLINEST`

returns one possible set of weights and statistics from this distribution. The default priors are a zero vector for the mean, an identity matrix for the covariance, and ones for the priors of the inverse-gamma distribution, but custom priors can be supplied. This ninth argument, the model identifier, exists to differentiate one Bayesian linear estimator from another on the same spreadsheet. If there are several Bayesian linear estimators with the same arguments on one spreadsheet, they will all return the same value; therefore, this ninth argument is provided to allow the user to implement multiple independent Bayesian linear estimators. For more information on the functions of the first four arguments to `BAYESLINEST`

, consult the documentation on `LINEST`

.

**Error Conditions:** The arguments to `BAYESLINEST`

must obey quite a few constraints. The first argument, `Y`

, must be a range. The second argument, `X`

, must, if present, be a range of the same size as `Y`

in one dimension (this dimension being the number of data points). The other dimension of `X`

is the number of features. The next argument, `const`

, is either `TRUE`

or `FALSE`

; the same holds for the fourth argument, `stats`

. The next two arguments, the shape and rate parameters for the inverse-gamma prior, must be nonnegative scalar numbers. The next argument is a prior on the mean, which must be a range the same size as the number of features. *However*, if `const`

is enabled, and it defaults to `TRUE`

, then a prior for the constant must be specified as well - therefore, in this case, the size of the mean prior must be one plus the number of features. The next argument is a prior on the covariance, a matrix, for which the same warning holds. If `const`

is disabled, the covariance must be a square symmetric matrix whose row length is the number of features; if `const`

is enabled, the covariance must be a square symmetric matrix whose length is one plus the number of features. The ninth argument, which is optional, must be an integer.

(↩)

**Parameters:** At least two: first a number of sums `N`

, and second, a type of distribution in double quotes, just as in `ACTUAL`

. Again, as in `ACTUAL`

, the next parameters are the parameters of the appropriate distribution.

**Return Type:** Depends on the return type of the specified distribution.

**Description:** The command `COMPOUND`

computes the sum of `N`

random variables of the distribution sent in. That is, `N`

random samples are taken independently from the supplied distribution and then added together. For example, `=COMPOUND(100, "gaussian", 5, 1)`

computes the sum of 100 independent Gaussian random variables each with mean 5 and standard deviation 1. In general, `COMPOUND`

is able to add up no more than `N=10,000`

sums, and will fail if made to. However, for many distributions, `COMPOUND`

automatically performs calculations that allow it to compute an unlimited number of sums. This unlimited form of `COMPOUND`

is only available when generating scenarios.

**Error Conditions:** The number of sums `N`

must be a number between 0 and 10,000. The distribution parameter must be a string and a valid *Scenarios* distribution. The next parameters must obey the error conditions of the supplied distribution type, just as in `ACTUAL`

. For example, the beta distribution must take two numbers greater than zero: `=BETA(-1, -1)`

is invalid, and therefore so is `=COMPOUND(100, "beta", -1, -1)`

.

(↩)