mean: numeric vector representing expectation of multivariate normal vector (distribution).
sigma: positively defined numeric matrix representing covariance matrix of multivariate normal vector (distribution).
given_ind: numeric vector representing indexes of multivariate normal vector which are conditioned at values given by given_x argument.
given_x: numeric vector which i-th element corresponds to the given value of the given_ind[i]-th element (component) of multivariate normal vector. If given_x is numeric matrix then it's rows are such vectors of given values.
dependent_ind: numeric vector representing indexes of unconditional elements (components) of multivariate normal vector.
is_validation: logical value indicating whether input arguments should be validated. Set it to FALSE to get performance boost (default value is TRUE).
is_names: logical value indicating whether output values should have row and column names. Set it to FALSE to get performance boost (default value is TRUE).
control: a list of control parameters. See Details.
n_cores: positive integer representing the number of CPU cores used for parallel computing. Currently it is not recommended to set n_cores > 1 if vectorized arguments include less then 100000 elements.
Returns
This function returns an object of class "mnorm_cmnorm".
An object of class "mnorm_cmnorm" is a list containing the following components:
mean - conditional mean.
sigma - conditional covariance matrix.
sigma_d - covariance matrix of unconditioned elements.
sigma_g - covariance matrix of conditioned elements.
sigma_dg - matrix of covariances between unconditioned and conditioned elements.
s12s22 - equals to the matrix product of sigma_dg
and solve(sigma_g).
Note that mean corresponds to μc while sigma
represents Σc. Moreover sigma_d is ΣId,Id, sigma_g is ΣIg,Ig
and sigma_dg is ΣId,Ig.
Since Σc do not depend on X(g) the output sigma does not depend on given_x. In particular output sigma remains the same independent of whether given_x is a matrix or vector. Oppositely if given_x is a matrix then output mean is a matrix which rows correspond to conditional means associated with given values provided by corresponding rows of given_x.
The order of elements of output mean and output sigma depends on the order of dependet_ind elements that is ascending by default. The order of given_ind elements does not matter. But, please, check that the order of given_ind match the order of given values i.e. the order of given_x columns.
Details
Consider m-dimensional multivariate normal vector X=(X1,...,Xm)T∼N(μ,Σ), where E(X)=μ and Cov(X)=Σ are expectation (mean) and covariance matrix respectively.
Let's denote vectors of indexes of conditioned and unconditioned elements of X
by Ig and Id respectively. By x(g) denote deterministic (column) vector of given values of XIg. The function calculates expected value and covariance matrix of conditioned multivariate normal vector XId∣XIg=x(g). For example if Ig=(1,3) and x(g)=(−1,1) then Id=(2,4,5)
Note that Σ(A,B), where A,B∈{d,g}, is a submatrix of Σ generated by intersection of IA
rows and IB columns of Σ.
Below there is a correspondence between aforementioned theoretical (mathematical) notations and function arguments:
mean - μ.
sigma - Σ.
given_ind - Ig.
given_x - x(g).
dependent_ind - Id
Moreover Σ(Ig,Id) is a theoretical (mathematical) notation for sigma[given_ind, dependent_ind]. Similarly μg
represents mean[given_ind].
By default dependent_ind contains all indexes that are not in given_ind. It is possible to omit and duplicate indexes of dependent_ind. But at least single index should be provided for given_ind without any duplicates. Also dependent_ind and given_ind should not have the same elements. Moreover given_ind
should not be of the same length as mean so at least one component should be unconditioned.
If given_x is a vector then (if possible) it will be treated as a matrix with the number of columns equal to the length of mean.
Currently control has no input arguments intended for the users. This argument is used for some internal purposes of the package.