finished function to get the probability mass function