Multivariate Gaussian Distribution Plotting of 4 Variable Data

3 ビュー (過去 30 日間)
Taha Erkam Orhan
Taha Erkam Orhan 2020 年 5 月 9 日
コメント済み: Taha Erkam Orhan 2020 年 5 月 10 日
Hello I'm working on classification of Iris data set which has 4 variable: Setal length-width, Petal length-width. I have calculated the 4x4 covariance and mean values. How can I plot Gaussian distribution of this data set. I couldn't plot it via using Mvnpdf function in the link. I would be appreciated if you could help me. Thanks.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 9 日
You are trying to visualize a 5D function. It is not easy to visualize such a function on a single graph. The easiest way is to make several graphs and show a higher dimensional slice of the function. See the following example. It uses the Setal length (SL) and Setal width (SW) on the x and y-axis. And uses the values of Petal length (PL) and Petal Width (PW) is used the higher dimensional variables to create several graphs.
rng(0);
mu = rand(1, 4);
sigma = rand(4);
sigma = sigma*sigma.'; % positive definite
sl = -3:0.1:3;
sw = -3:0.1:3;
pl = 0:1:2;
pw = 0:1:2;
[SL, SW, PL, PW] = ndgrid(sl, sw, pl, pw);
X = [SL(:) SW(:) PL(:) PW(:)];
Y = mvnpdf(X, mu, sigma);
Y = reshape(Y, size(SL));
figure;
tiledlayout('flow');
for i=1:numel(pl)
for j=1:numel(pw)
nexttile
surf(sl, sw, Y(:,:,i,j));
title(sprintf('PL=%.2f, PW=%.2f', pl(i), pw(j)));
shading interp
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by