1
$\begingroup$

Let $X=(X_1,...,X_n)$ denote the multinormal distribution with covariance matrix $\Sigma$. Then $$\texttt{RandomVariate}[\texttt{MultinormalDistribution}[\Sigma]]$$ samples this distribution.

Question: Say we want to condition the random variable on something, for instance that $X_{i_k}=x_k$ is a particular number for $k=1,...,r$. How do I sample $\texttt{MultinormalDistribution}[\Sigma]$ conditionally on these restrictions?

$\endgroup$
1
  • $\begingroup$ If this is a Mathematica software question, please provide the code you have tried and the problems you encountered. Otherwise, you probably should post this question on Mathematics instead. $\endgroup$
    – bbgodfrey
    Commented Nov 9, 2021 at 17:46

1 Answer 1

2
$\begingroup$

If you're willing to take it on faith that the distribution of the remaining random variables given $X_1=x_1$ is a multivariate normal, then the following approach should work. (And I've replaced the conditioned value $x_1$ with $z$.)

r = 3;
Σ = Table[σ[Min[i, j], Max[i, j]], {i, r}, {j, r}];
dist = MultinormalDistribution[{{σ11, σ12, σ13}, {σ12, σ22, σ23}, {σ13, σ23, σ33}}];
μGivenx1[i_] := Expectation[x[i] \[Conditioned] x[1] == z, Table[x[k], {k, r}] \[Distributed] dist]
covGivenx1[i_, j_] := Expectation[(x[i] - μGivenx1[i]) (x[j] - μGivenx1[j]) \[Conditioned] x[1] == z, 
  Table[x[k], {k, r}] \[Distributed] dist]
distGivenx1 = MultinormalDistribution[Table[μGivenx1[i], {i, 2, r}],
  Table[covGivenx1[i, j], {i, 2, r}, {j, 2, r}]];

Then just assign values to the terms in $\Sigma$ and use RandomVariate on distGivenx1.

Here is a specific example:

r = 3;
z = 1.2;
Σ = {{1, .5, .3}, {0.5, 3, 0.2}, {0.3, 0.2, 2}};
dist = MultinormalDistribution[Σ];
μGivenx1[i_] := Expectation[x[i] \[Conditioned] x[1] == z, 
  Table[x[k], {k, r}] \[Distributed] dist]
covGivenx1[i_, j_] := Expectation[(x[i] - μGivenx1[i]) (x[j] - μGivenx1[j]) \[Conditioned] x[1] == z, 
  Table[x[k], {k, r}] \[Distributed] dist]
distGivenx1 = MultinormalDistribution[Table[μGivenx1[i], {i, 2, r}], 
   Table[covGivenx1[i, j], {i, 2, r}, {j, 2, r}]];
SeedRandom[12345];
RandomVariate[distGivenx1, 4]
(* {{-1.03966, -1.9972}, {3.58599, 0.964509}, {-0.450731, 0.0574758}, {1.09308, -0.670069}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.