Cumulative distribution function: plot in Matlab

4 vues (au cours des 30 derniers jours)
Lorenzo Fabbri
Lorenzo Fabbri le 15 Déc 2016
Commenté : Star Strider le 16 Déc 2016
I have a matrix created with mvnrnd in Matlab with mean value being a 2x1 vector, variance being a 2x2 matrix and N=10000. I have to compute the cumulative distribution function and plot it. I did the following:
cdf_sample = mvncdf(data, mu, cov);
[X1, X2] = meshgrid(linspace(-1,3,100)', linspace(-3,1,100)');
surf(X1, X2, reshape(cdf_sample, 100, 100));
It works, but the result is quite strange (not the nice smooth plot [1] that you see usually). What did I do wrong? Thanks.

Réponses (1)

Star Strider
Star Strider le 15 Déc 2016
‘What did I do wrong?’
You did not attach your ‘data’ file for one.
Note that in the mvncdf documentation you linked to, ‘X’ is a (625x2) matrix. We have no idea what your ‘data’ are, or their structure or dimensions. I suspect that the structure of your ‘data’ array is the source of your problem. It needs to match the structure of ‘X’ in the documentation.
  2 commentaires
Lorenzo Fabbri
Lorenzo Fabbri le 16 Déc 2016
Thanks for the answer. Data is the result of mvncdf, so it is a Nx2 matrix.
Star Strider
Star Strider le 16 Déc 2016
That may be the problem. It apparently has to have the same structure as in the documentation to get the same result.
Sorting it by the first column (use the sortrows function with the default 'ascend' option) could be the solution.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by