# Identifying a probability mass function

In my stats class, we're given the following problem:

Consider the following discrete variable $X$ which can only take the values $X \in \{1,2,3\}$. Some observations are recorded for this variable: $\{1,1,1,2,1,3,1,3,1,1,3,3,3,2\}$. (I've truncated the list here, as its quite long).

Anyhow, the question is how would one form the PMF, and calculate for example, the probability of observing a $1$ or a $2$ or $3$, etc...

Is there a "better" way than simply drawing the histogram?

## 2 Answers

Let $X$ be a discrete random variable and let $p$ be the probability mass function (pmf) of $X$. Write $P(X=x)$ to mean the probability of observing $x$. Then $$p(x)= P(X=x) = \begin{cases} \dfrac{\mbox{the number of occurrences of }x}{\mbox{total number of occurrences}} &\mbox{ if } x = 1,2,3, \\ \hspace{2cm} 0 &\mbox{ otherwise}. \end{cases}$$

So for your occurrences: $1,1,1,2,1,3,1,3,1,1,3,3,3,2$, the pmf is $$p(x) = \begin{cases} \frac{1}{2} &\mbox{ if } x=1, \\ \frac{1}{7} &\mbox{ if } x=2, \\ \frac{5}{14} &\mbox{ if } x=3, \\ 0 &\mbox{ otherwise}. \\ \end{cases}$$

Just add the number of occurrences of $1$, $2$, and $3$ and divide by their sum to get the PMF.