When computing the sample variance numerically, the mean must be computed
before
can be determined. This requires storing the set of sample values. However, it is
possible to calculate
using a recursion relationship involving only the last sample
as follows. This means
itself need not be precomputed, and only a running set of
values need be stored at each step.
In the following, use the somewhat less than optimal notation to denote
calculated from the first
samples (i.e., not the
th moment)
(1)
|
and let
denotes the value for the bias-corrected sample variance
calculated from the first
samples. The first few values calculated for the mean
are
(2)
| |||
(3)
| |||
(4)
|
Therefore, for , 3 it is true that
(5)
|
Therefore, by induction,
(6)
| |||
(7)
| |||
(8)
| |||
(9)
|
By the definition of the sample variance,
(10)
|
for .
Defining
,
can then be computed using the recurrence equation
(11)
| |||
(12)
| |||
(13)
| |||
(14)
|
Working on the first term,
(15)
| |||
(16)
|
Use (◇) to write
(17)
|
so
(18)
|
Now work on the second term in (◇),
(19)
|
Considering the third term in (◇),
(20)
| |||
(21)
| |||
(22)
|
But
(23)
|
so
(24)
| |||
(25)
|
Finally, plugging (◇), (◇), and (◇) into (◇),
(26)
| |||
(27)
| |||
(28)
| |||
(29)
|
gives the desired expression for in terms of
,
, and
,
(30)
|