A problem with mvnrnd and mvnpdf
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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));
0 comentarios
Respuestas (1)
John D'Errico
el 25 de Ag. de 2016
Editada: John D'Errico
el 25 de Ag. de 2016
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 comentario
Niklas Rottmayer
el 4 de Oct. de 2019
Editada: Niklas Rottmayer
el 4 de Oct. de 2019
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)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!