using contour()

4 ビュー (過去 30 日間)
Bahareh
Bahareh 2011 年 4 月 16 日
I have a distribution with a 1x2 mean vector and a 2x2 covariance matrix. I would like to display the distribution using contour(). Can you please help me?

採用された回答

Teja Muppirala
Teja Muppirala 2011 年 4 月 16 日
Say your mean is m, and your covariance is S.
m = [1 2];
S = [2 1; 1 10];
The easy way: If you have the statistics toolbox, there is a function called "gmdistribution"
G = gmdistribution(m,S)
F = @(x,y) pdf(G,[x y])
ezcontour(F)
The hard way: Find the equation for a multivariate normal distribution on Wikipedia:
It's at the top right hand side, and type that long expression into MATLAB:
F = @(x,y) (1/2*pi) * (1/sqrt(det(S))) * exp(-0.5* ...
ezcontour(F)
  1 件のコメント
Bahareh
Bahareh 2011 年 4 月 16 日
Thanks a lot.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by