use matlab code to draw the joint PMF and CDF

52 次查看(过去 30 天)
Hi, I am here confused about how to use 3D plot to draw the PMF (Probability Mass function) and CDF(Cumulative Distribution Function) based on x y two random variables. (The PMF I can draw it on paper but have no idea how to generate a code). Appreciate for the help
I tried the code below but it did not generate the graph what it supposed to be.
plot3([0 0 0],[0 0 0],[0 0 0.25])
hold on
plot3([1 0 0],[0 0 0],[0 0 0.125])
plot3(1, 0, 2)
hold on
plot3([0 0 0],[0 1 0],[0 0 0.5])
hold on
xlabel('X')
ylabel('Y')
zlabel('Probability')
grid on

回答(1 个)

Chunru
Chunru 2021-11-28
编辑:Chunru 2021-11-28
[x, y] = meshgrid([0 1], [0 1])
x = 2×2
0 1 0 1
y = 2×2
0 0 1 1
z = [0.25 0.5; 0.125 0.125]';
stem3(x, y, z)
xlabel('x');
ylabel('y');
zlabel('p')

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics and Visualization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by