Cumulative distribution function: plot in Matlab

4 次查看(过去 30 天)
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.

回答(1 个)

Star Strider
Star Strider 2016-12-15
‘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 个评论
Lorenzo Fabbri
Lorenzo Fabbri 2016-12-16
Thanks for the answer. Data is the result of mvncdf, so it is a Nx2 matrix.
Star Strider
Star Strider 2016-12-16
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.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by