Multivariate Normal Distribution with Nine Random variables

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

 Réponse acceptée

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 commentaires

Dear Cyclist
Thank you so much for the answer.
Actually, my problem is to define the correlation matrix (Sigma) manually will take huge time.I just showed here the example of nine but I have hundreds of variable spread in a circle. Farther you go from the centre of circle less will be the correlation. MATLAB has a function "gsusmf", for the given correlation length it can give the correlation matrix but I am able to make it work if the circuit is in the straight line. Isn't their anyway to do it when the circuit is arranged in a circle? or isn't there any way to prepare the sigma matrix automatically?
It sounds like you have a pretty specialized case, so I would not expect there to be any kind of built-in function that will do what you want. So it won't be "automatic".
But you might be able to build something programatically, since it would be too tedious to type the matrix in manually. I suggest you post a separate question where you give sufficient detail about the properties you want your correlation matrix to have. (Maybe post a link to that new question here.)
Thank you so much cyclist. I will first try to build the program myself than I will port the if I won't be able to achieve it.
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!
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).
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by