how do we plot a bivariate normal distribution from one side?

조회 수: 4 (최근 30일)
ektor
ektor 2016년 11월 19일
편집: Marina Kiseleva 2018년 9월 4일
Dear all
I plot the following bivariate distribution
mu = [0 0];
Sigma = [.25 .3; .3 1];
x1 = -3:.2:3; x2 = -3:.2:3;
[X1,X2] = meshgrid(x1,x2);
F = mvnpdf([X1(:) X2(:)],mu,Sigma);
F = reshape(F,length(x2),length(x1));
surf(x1,x2,F);
caxis([min(F(:))-.5*range(F(:)),max(F(:))]);
axis([-3 3 -3 3 0 .4])
xlabel('x1'); ylabel('x2'); zlabel('Probability Density');
My question is how do I plot the joint density from the vantage point of x1 or x2? So I want to obtain a 2D graph that shows x1 (or x2) on the x-axis and the density values on the y-axis
Any help is greatly appreciated.
Thanks in advance

채택된 답변

Marina Kiseleva
Marina Kiseleva 2018년 9월 4일
편집: Marina Kiseleva 2018년 9월 4일
You can plot the marginal distribution of x or y separately, using whatever variance and mean corresponds to it (page 4 of this link ).
For you, I think x1 has a sigma^2 of 0.25, and a mean of 0, so you can plot it like:
x = -3:.2:3;
density = normpdf(x, 0, sqrt(0.25));
plot(x, density);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by