Discrete random variable (source code)

= Discrete random variable

A <random variable> is discrete when some finite or <countable set> $D\subseteq\mathbb R$ has $\mathbb P(X\in D)=1$. Its <probability mass function> is $p_X(x)=\mathbb P(X=x)$; these nonnegative masses sum to one. An <event> determined by the value has <probability> $\mathbb P(X\in A)=\sum_{x\in A\cap D}p_X(x)$. Values outside $D$ may still occur on a <zero-probability event> without changing this definition.

Countable support need not consist of <integers>: a random variable constantly equal to $3/2$ is discrete. Integer-indexed <tail-sum formulas> therefore require a separate integer-valued hypothesis. For the dice sum in <random variable>, the <expected value> is $\sum_{s=2}^{12}s\,p_S(s)=7$ and the <variance> is $\sum_{s=2}^{12}(s-7)^2p_S(s)=35/6$; the same answer follows by adding the <variances> of its <independent> summands.