Linux Kernel
3.7.1
|
#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 ewma * | ewma_add (struct ewma *avg, unsigned long val) |
EXPORT_SYMBOL (ewma_add) | |
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 .
EXPORT_SYMBOL | ( | ewma_init | ) |
EXPORT_SYMBOL | ( | ewma_add | ) |