Reputation: 39
I am new to matlab and would like to know how to plot a graph when it states
a = -1 0 1 2 3
----------------------------------
p(a)1/24 1/2 1/4 1/6 1/24
Any tips on how to do it would be helpful!
Upvotes: 0
Views: 13179
Reputation: 3562
Because this shows up high when searching for MATLAB PMF, an alternative way to plot discrete probability distributions is the stem
function.
a = [-1 0 1 2 3]; p = [1/24 1/2 1/4 1/6 1/24];
stem(a,p);
set(gca, 'xlim', [-1.5 3.5]);
Upvotes: 1
Reputation: 7469
For a probability mass function, I would use bar
>> a = [-1 0 1 2 3]; p = [1/24 1/2 1/4 1/6 1/24]; bar(a,p)
Upvotes: 1