Database Reference
In-Depth Information
amount of added noise. In the case of
Figure 11.1
,
a window of 30, perhaps
35 would best recover the underlying signal.
Weighted Moving Average
The weighted moving average is a generalization of the standard moving
average that uses different weights for each of the elements in the window.
This collection of weights is known as the
kernel
; various kernels are
standard in different industries. The normal moving average is simply a
weighted moving average with a kernel that assigns
1/k
to all values.
Implementing a weighted moving average is a little more complex:
public class
WeightedMovingAverage {
double
[] kernel;
double
[] values;
double
kernelSum = 0.0;
int
k = 0;
long
N = 0;