If we have a discrete random variable x and the data pertaining to it in X(n), how in matlab can we determine the probability mass function pmf(X)?
To add yet another option (since there are a number of functions available to do what you want), you could easily compute the pmf using the function ACCUMARRAY if your discrete values are integers greater than 0:
pmf = accumarray(X(:),1)./numel(X);
Here's an example:
>> X = [1 1 1 1 2 2 2 3 3 4]; %# A sample distribution of values
>> pmf = accumarray(X(:),1)./numel(X) %# Compute the probability mass function
pmf =
0.4000 %# 1 occurs 40% of the time
0.3000 %# 2 occurs 30% of the time
0.2000 %# 3 occurs 20% of the time
0.1000 %# 4 occurs 10% of the time