Discrete Variables
Consider a function that can only take on a discrete set of values.
Examples are flipping a coin (either heads or tails, 2 possible
values), rolling a dice (6 possible values), the allowed energy
levels of the hydrogen atom (En = -2.18 x 10-18J/n2). We wish
to evaluate the average of this function. For starters, consider
a coin flip. Assume that the probability of obtaining heads is
the same as the probability for obtaining tails (hence, each has
a probability of ½ of occurring). Consider the following
function of the coin flip:
To see this, consider an example: The coin is flipped 1000 times,
500 times the result is heads, 500 times the result is tails.
The average value of f in this example would be calculated in
the standard manner:

which is just the result we started out to prove. In general,
then, the average of a discrete variable is simply
where x can take on a discrete set of values (x1, x2,
),
f(x) is a function of x, and p(xi) is the probability of x taking
on the value xi.
Continuous Variables
Continuous variables can take on an infinite set of values. Examples
include the position of a particle, the velocity of a particle,
the pressure of a gas, etc. Given the above result, it is straightforward
to evaluate the average of a function of a continuous variable:
where p and f are defined in a manner similar to their definitions
for discrete variables.