function geom_pmf
% A trial results in either success (with probability p) or failure
p = 1/6;                     % e.g. a roll of a die showing a 6
% define a r.v. X that represents the num of trials required before a success
% occurs. Theoretically, X can take values larger than any finite number of 
% trials one can name, but consider only a few values:
X = 0:25
% Ask matlab to compute the probability of X taking each one of these integer values:
Y = geopdf(X, p)
% figure(1)
% stem(X, Y, 'MarkerFaceColor','green')
% title(sprintf('Geometric PMF with parameter p = %.4f', p))
figure
plot(X, Y, '--bo','LineWidth',2,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',10)
title(sprintf('Geometric PMF with parameter p = %.4f', p))
% the shape is reminiscent of an exponentially decaying function, which is
% no accident of course. goepdf is the discrete counterpart of an
% exponentially distributed continuous r.v., as we'll see. 
end