Hello,

I am struggling on the problem of obtaining multivariate normal distribution with its mean vector non zero. For example, I have a bivariate vector z=[z1 z2], and from the command cdfMvn(), it seems that I can only have bivariate standard normal CDF evaluated at z with mean zero for both z1 and z2. If I wish to have the mean of z1 and z2 to be, say, 1, how should I proceed to obtain it?

Thank you so much for the help.

## 2 Answers

The simplest method is probably to simply subtract the mean from each of the variables that you pass to `cdfMVn`

. Here is a modification of one of the examples from the manual, which illustrates this

```
//Upper limits of integration
ulim = { -0.5, 1 };
//Correlation matrix
corr = { 1 0.26,
0.26 1 };
//Calculate cumulative probability of
//the first variable being ≤ -0.5
//and the second variable being ≤ 1
//ASSUMING MEAN IS ZERO for both variables
p = cdfmvn(ulim, corr);
print p;
```

This code will return `p`

as equal to 0.28024725. Now we will create a mean for each variable and then subtract it from the limits of integration passed to `cdfMVn`

.

```
//Means for each variable
mu = { 0.76, 1.1 };
p2 = cdfmvn(ulim - mu, corr);
print p2;
```

In this case, `p2`

is equal to 0.066579035. Now if you think about it for a bit, it may make intuitive sense that the limits of integration are distances from the mean of the distribution when the mean is zero, so all we have to do is modify the input in the manner above.

However, GAUSS also has a more advanced function, `cdfMVne`

which allows you to specify means for each variable. So I will also demonstrate its use for comparison.

```
{ p2, tol, err } = cdfMvne(cdfmControlCreate(), ulim_t, corr, mu_t);
print p2;
```

After this code, `p2`

will be equal to 0.066579035 as we expect.

Now that we have seen how to do it, we may want something simpler so that we do not always have to remember the subtraction of the mean. If so, we can create a simple GAUSS `proc`

that will do this for us. We can use either of the functions above. Here is an example of one method

```
print cdfMVnmu(ulim, corr, mu);
proc (1) = cdfMVnmu(x, corr, mu);
retp(cdfMVn(x - mu, corr));
endp;
```

This code will again give us the answer 0.066579035. If it is something you will use fairly often, then you can add it to your GAUSS `user`

library so that it is always available for you to use. If you have any questions about that, we are happy to help. Please post that request as a new question, to enable the forum to be easier for others to search for answers.

@aptech thank you so much for such a detailed answer! That really helps a lot!