Linux Kernel
3.7.1
|
Go to the source code of this file.
Data Structures | |
struct | ewma |
Functions | |
void | ewma_init (struct ewma *avg, unsigned long factor, unsigned long weight) |
struct ewma * | ewma_add (struct ewma *avg, unsigned long val) |
ewma_add() - Exponentially weighted moving average (EWMA) : Average structure : Current value
Add a sample to the average.
DOC: Exponentially Weighted Moving Average (EWMA)
These are generic functions for calculating Exponentially Weighted Moving Averages (EWMA). We keep a structure with the EWMA parameters and a scaled up internal representation of the average value to prevent rounding errors. The factor for scaling up and the exponential weight (or decay rate) have to be specified thru the init fuction. The structure should not be accessed directly but only thru the helper functions. ewma_init() - Initialize EWMA parameters : Average structure : Factor to use for the scaled up internal value. The maximum value of averages can be ULONG_MAX/(factor*weight). For performance reasons factor has to be a power of 2. : Exponential weight, or decay rate. This defines how fast the influence of older values decreases. For performance reasons weight has to be a power of 2.
Initialize the EWMA parameters for a given struct ewma .