Multivariate Nomral Distribution Matlab

3 ビュー (過去 30 日間)
Shahnewaz Karim Sakib
Shahnewaz Karim Sakib 2019 年 10 月 15 日
I want to generate multivariate normal joint distribution for a 3*3 matrix. Say I have mu = [0.4 0.5] and sigma = [0.25 03; 0.45 0.5]. As I wanted to generate a 3*3 joint distribution, I decided to do the following:
mu = [0.4 0.5];
sigma = [0.25 0.3; 0.3 0.5];
x1 = 1:3;
x2 = 1:3;
[X1,X2] = meshgrid(x1,x2);
X = [X1(:) X2(:)];
y = mvnpdf(X,mu,sigma);
My assumption is that X now has 3*3 matrix index. If the value is 3 1 it means X = 3, Y = 1. For example, if I print the value of X I get:
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
So, my assumption was the final pdf will be a 9*1 vector and each value will represent the probability of each row. For example, if the second value is 0.05, it will indicate P(X=1,Y=2) = 0.05.
When I gey y, I get the following:
y =
0.3484
0.0471
0.0000
0.0000
0.0027
0.0015
0.0000
0.0000
0.0000
However, as y is a joint distribution, the sum(y) should have been 1. But here it's 0.3997.
Can anyone tell me what am I doing wrong here? And why the sum is not 1?

採用された回答

Jeff Miller
Jeff Miller 2019 年 10 月 16 日
If you have only those 9 discrete combinations, then you can make their probabilities be any values you want (summing to one). For example, you could use the PDF values and rescale them to sum to one. Whether this is a good idea or not, I cannot say, since I have no idea what you are trying to achieve.
No, there is no representation of Gaussian over the integers 1, 2, and 3.
  1 件のコメント
Shahnewaz Karim Sakib
Shahnewaz Karim Sakib 2019 年 10 月 16 日
Yeah. This makes sense. Thanks!

サインインしてコメントする。

その他の回答 (1 件)

Jeff Miller
Jeff Miller 2019 年 10 月 16 日
I don't see anything wrong with what you are doing, but only with your expectations about things summing to 1.
In general, the PDF values of continuous distributions don't sum to 1. Instead, the total area under the distribution integrates to 1, which is quite different.
Among other things, note that you are considering only the integer values 1,2,3 for the random variables, but in a multivariate normal the random variables are real-valued, so values like 1.11107, 2.5632, etc are also possible. Even if PDF values summed to one (which they do not), you would not get that sum here because you are ignoring all of these non-integer possibilities.
  1 件のコメント
Shahnewaz Karim Sakib
Shahnewaz Karim Sakib 2019 年 10 月 16 日
Ok. I was trying to find the probabilites for the discrete distribution. That's why I have only considered the discrete values. Would it be a good idea to use those values and rescale them to represent the discrete joint distribtion? Moreover, I think Gaussian represents continuous distribtuion. Is there any representation of Gaussian in discrete domain?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by