Sample and weighted mean, expected value

The sample mean (or, average) of given numbers x_1,ldots,x_n, is defined as

 hat{x} := frac{1}{n} ( x_1 + ldots + x_n) .

The sample average can be interpreted as a scalar product:

 hat{x} = p^Tx,

where x = (x_1,ldots,x_n) is the vector containing the samples, and p = (1/n) mathbf{1}, with mathbf{1} the vector of ones.

More generally, for any vector p in mathbf{R}^n, with p_i ge 0 for every i, and p_1+ldots+p_n = 1, we can define the corresponding weighted average as p^Tx. The interpretation of p is in terms of a discrete probability distribution of a random variable X, which takes the value x_i with probability p_i, i=1,ldots,n. The weighted average is then simply the expected value (or, mean) of X under the probability distribution p. The expected value is often denoted mathbf{E}_p(X), or mathbf{E}(X) if the distribution p is clear from context.