Gaussian(meanVec, covar, I, J)
A multi-variate Gaussian distribution based on a mean vector «m» and covariance matrix «cv». A single point sampled from this distribution is indexed by «I».
- «meanVec»: Indexed by «I». The mean.
- «covar»: Covariance matrix, indexed by «I» and «J». The diagonal contains the variances. This matrix must be symmetric and positive-definite.
- «I»: Index for «meanVec» and for the result.
- «J»: An index of the same length as «I», used by «covar»
- «over»: (optional) Additional indexes to sample independently over.
- «fast»: (optional) Seldom specified. When omitted or false, the covariance of the sample generated will match «covar» almost exactly. Doing so requires a small amount of additional work by the function. When specified as true, this step is skipped and the actual covariance of the sample is subject to sampling error, and hence may differ slightly and randomly from «covar». The main reason to use this parameter would be if you need to match the numeric results obtained from the older Gaussian UDF prior to Analytica 5.0 exactly after upgrading.
When «covar» is not positive-definite, an error is thrown when requesting a single random sample (using
Random(Gaussian(...))) or when requesting a Sample. The error is not issued from Mid-mode. The error can be caught using Try().
In Analytica 5.0 and later, this is a built-in function.
For earlier releases, you must add this library to your model before using:
Index I := [1, 2, 3, 4]
Index J := [1, 2, 3, 4]
Variable M :=
I ▶ 1 2 3 4 10 -5 0 7
Variable CV :=
I ▶ J ▼ 1 2 3 4 1 1 -2 4.8 6.3 2 -2 16 -51.2 -7.2 3 4.8 -51.2 256 57.6 4 6.3 -7.2 57.6 81
Gaussian(M, CV, I, J) →
(The above graphs are scatter plots in sample view, using
I as the coordinate index.)
Single Random Sample
Gaussian may be used with the Random function to generate a single random vector, indexed by «I», drawn from the multi-variate Gaussian distribution. Using the above variables, the usage is:
Random(Gaussian(M, CV, I, J))
The optional «Over» parameter can also be used with Gaussian to generate multivariate samples that are independent over additional indexes. For example, to generate an independent Gaussian for each element of Index
Gaussian(M, CV, I, J, Over: K)
- In Analytica 5.0, this has been included as a built-in function. Also, starting in Analytica 5.0, the sample covariance of the sample generated by the algorithm matches the «covar» precisely, or almost precisely.
- Prior to Analytica 4.6, this function was in the Multivariate Distributions library.
- Dens_Gaussian : The probability density of a Gaussian at x
- MultiNormal : For multi-D normal (Gaussian) using correlation, rather than covariance
- Normal : for 1-D normal
- Normal_correl : For 2-D normals
- Covariance : For estimating covariance from data
- Kernel Density Smoothing
- Multivariate distributions
- Multivariate Distributions.ana
- Distribution Densities Library