A problem with mvnrnd and mvnpdf

조회 수: 3 (최근 30일)
Lening Li
Lening Li 2016년 8월 25일
편집: Niklas Rottmayer 2019년 10월 4일
Hi, I am using mvnrd to generate samples for 100 examples. Then I use mvnpdf to evaluate the possibility of these samples. But the possibilities I got are all 0. I just want to get samples from multivariate normal distribution. Here is the code H = mvnrnd(zeros(1, 620), eye(620), 100); mvnpdf(H(1,:),zeros(1, 620), eye(620));

답변 (1개)

John D'Errico
John D'Errico 2016년 8월 25일
편집: John D'Errico 2016년 8월 25일
First of all, you could simply have used randn instead of mvnrnd, since these are unit variance, uncorrelated normal deviates, with zero mean.
Next, I think you don't understand what is a PDF. It does NOT compute probability. Worse, you talk about possibility. "possibility" has no defined mathematical meaning in this context.
https://en.wikipedia.org/wiki/Probability_density_function
Yes, I know, the word probability is in there. PDF always seemed like a bad name to me. Anyway, you cannot talk about the "probability" of getting some exact value from a continuous probability distribution. That event has measure zero. For good measure, re-read this page:
https://en.wikipedia.org/wiki/Probability_density_function
You can talk about probability in terms of an integral over some region of a PDF. This is normally done using the CDF.
Finally, in 620 dimensions, the curse of dimensionality hits hard. You can compute the pdf and have it be non-zero in a LOW number of dimensions. (It still is NOT a probability. Nor is it a possibility, whatever that means to you.)
H = randn(1,3); mvnpdf(H,zeros(1, 3), eye(3))
ans =
0.0240378739470385
But if you truly expected to see some non-zero result from this computation in 620 dimensions in floating point arithmetic, think again. It won't happen terribly often, unless the random sample is very, very, very near the origin.
So, try it using a symbolic form instead:
H = randn(1,620); mvnpdf(vpa(sym(H)),zeros(1, 620), eye(620))
ans =
1.1480262115996036255890868011796e-386
  댓글 수: 1
Niklas Rottmayer
Niklas Rottmayer 2019년 10월 4일
편집: Niklas Rottmayer 2019년 10월 4일
Hey, i have a similar problem with dimensionality but when i apply vpa to my variable i get an error message using mvnpdf. They use bsxfun(@rdivide,X0,T) with X0 the 0 mean data and T as matrix of standarddeviations. When i change the line to rdivide(X0,T); it workds without a problem. A friend of mine applied the same as you did and it worked out. Why is that? (2019b Version)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by