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)?
Maybe try making just a function handle so you don't need to store another array:
pmf = @(x) arrayfun(@(y) nnz(DATA==y)/length(DATA),x);