Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
average.h File Reference

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 ewmaewma_add (struct ewma *avg, unsigned long val)
 

Function Documentation

struct ewma* ewma_add ( struct ewma avg,
unsigned long  val 
)
read

ewma_add() - Exponentially weighted moving average (EWMA) : Average structure : Current value

Add a sample to the average.

Definition at line 54 of file average.c.

void ewma_init ( struct ewma avg,
unsigned long  factor,
unsigned long  weight 
)

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 .

Definition at line 37 of file average.c.