A random variable maps outcomes from a sample space to numbers, making the outcomes easier to manipulate. For example, there isn’t much to be done with outcomes from the coin-flip sample space { H, T }, but mapping outcomes to integers with the random variable X = { (H, 0), (T,1) } allows mathematical manipulations. The mapping used depends on what’s being done. X's previous definition might be useful when counting the number of tails, while the definition X = { (H, 1), (T, -1) } is more suited for keeping track of wins and losses.
Given a random variable X over a sample space, the probability that Xequals a particular value k is the sum of the probabilities of the outcomes that X maps to k: Pr(X=k)=∑X(o)=kPr(o) For example, let the random variable X map the outcome i of a single die roll to i. The probability that X is even is Pr(even(X))=Pr(2)+Pr(4)+Pr(6)=1/6+1/6+1/6=1/2Computing the mean (or average or expected value) of a random value is a common mathematical manipulation. A random variable’s mean is the sum of the values in the range, with each value weighted by its probability: ∑k∈range(X)kPr(X=k) The mean is often represented by μ. To continue the die-roll example, X's mean is
1Pr(X=1)+2Pr(X=2)+⋯+6Pr(X=6)=1⋅1/6+2⋅1/6+⋯+6⋅1/6=(1+2+⋯+6)1/6=21⋅1/6=3.5A random variable’s mean is not necessarily a member of its range.