# Generate covariance matrix with fixed values in certain cells

I want to be able to generate a covariance matrix of dimensions $D$ x $D$, such that certain specified cells of this matrix contain a fixed predetermined values (at least approximately).

For e.g. For matrix, $S$ = $$\begin{matrix} a_{11} & a_{12} & \ldots & a_{1D}\\ a_{21} & a_{22} & \ldots & a_{2D}\\ \vdots & \vdots & \ddots & \vdots\\ a_{D1} & a_{D2} &\ldots & a_{DD} \end{matrix}$$

I want to make sure that certain $a_{i,j}$ 's have a predetermined value.

(If I were generating a covariance matrix without this constraint, I would just use a Wishart Random Generator. In Matlab, it would be something like - W = wishrnd([1 0.5; 0.5 3],30)/30)

One way I can think of this problem is that different cells of the covariance matrix have different degrees of freedom. So that the cells with fixed values can be assumed to have infinite degrees of freedom and the rest as some finite number.

• Is there any way to translate the constraint into one on the square root of the covariance? or the square root of the inverse covariance? – shabbychef Jul 22 '13 at 22:02

Alternatively, since you say you just need the values to be similar to their fixed values, you could just keep resampling with wishrnd until you get something that's close enough. See rejection sampling and Approximate Bayesian Computation. The MCMC-type methods from my first paragraph could be overkill.