MATLAB Answers

Multivariate Normal Distribution with Nine Random variables

17 views (last 30 days)
Hello, I have a circuit which has nine random variables (Wi, i = 1 to 9). The layout of the circuit is shown in the below image. The 5th random variable (W5) is correlated (say 90%) with W1-W9. Of course, W1 and W9 are less correlated compared to W1 and W5.
My question is how to use mvnpdf or mvnrnd functions in my case. All the examples I see is only with two variables. In my case, I have nine variables.
Thanks

  0 Comments

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 8 Mar 2018
Here is an example using four random variables. (It would be analogous to just your variables W1,W2,W4,W5.) It generates 100 observations of these four variables.
N = 100;
mu = [0 0 0 0];
sigma = [ ...
1.0 0.9 0.9 0.8; ...
0.9 1.0 0.8 0.9; ...
0.9 0.8 1.0 0.9; ...
0.8 0.9 0.9 1.0; ...
];
r = mvnrnd(mu,sigma,N)
Note how in the correlation matrix sigma, I've made nearest-neighbors have a correlation of 0.9, and the diagonally connected ones have 0.8. I think this captures the gist of what you were trying to do.
So, for your nine-variable case, you will need to define sigma as a 9x9 correlation matrix, and mu as a 1x9 vector of means.
An important thing to note is that the matrix needs to be "positive definite". Practically speaking, this means that your correlations need to be self-consistent with each other. For example, in your case, if (W1,W2) have 0.9 correlation, and (W2,W4) have 0.9 correlation, then it will not be possible for (W1,W4) to have a small correlation like 0.4. mvnrnd will give an error message if you try to define a non-sensible correlation matrix like that.
I hope that helps.

  6 Comments

Show 3 older comments
Matheus Henrique Fessel
Matheus Henrique Fessel on 22 Oct 2018
Hey guys, I just looked at the problem posed by Abi and I have a similar situation. The solution presented by the Cyclist works just fine, but I would like to know what is the proper way to plot the output of the mnvpdf function in the case of 3 or more variables, e.g. a surface plot or if it doesn't make sense to plot since the high dimension problem doesn't fit in a 3D graph.
Thanks in advance!
the cyclist
the cyclist on 22 Oct 2018
It's a continual challenge to display high-dimensional data in a meaningful way. I have a little bit of generic advice, and a little bit of specific advice.
The generic advice is to focus on the concept that you want to illustrate to the viewer, and try to make the visualization show that concept. An approach of "I want this one picture to show everything about my data" just doesn't work.
If it is important to show how each individual pair of variables is related to each other, then you might need to make lots of pairwise plots, or some kind of interactive gui or notebook where the user can select variables.
If you have lots of variables, sometimes a dimensional-reduction technique (e.g. pca) might be a useful pre-processing step to showing the data.
It might be useful to stroll through the MATLAB Plot Gallery to see examples of many different plot types, which might inspire you (and then you can directly steal the code from there).
Matheus Henrique Fessel
Matheus Henrique Fessel on 22 Oct 2018
It's indeed not trivial how to display high-dimensional data. I will follow your advices and check out these tools aforementioned and hopefully find the best way to plot these types of data.
In any case, I appreciate your attention and kindness!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!