Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
average.c File Reference
#include <linux/export.h>
#include <linux/average.h>
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/log2.h>

Go to the source code of this file.

Functions

void ewma_init (struct ewma *avg, unsigned long factor, unsigned long weight)
 
 EXPORT_SYMBOL (ewma_init)
 
struct ewmaewma_add (struct ewma *avg, unsigned long val)
 
 EXPORT_SYMBOL (ewma_add)
 

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.

EXPORT_SYMBOL ( ewma_init  )
EXPORT_SYMBOL ( ewma_add  )