lkml.org 
[lkml]   [2010]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3] Add generic exponentially weighted moving average (EWMA) function
From
Date
On Wed, 2010-10-20 at 17:23 +0900, Bruno Randolf wrote:
> +/**
> + * ewma_add() - Exponentially weighted moving average (EWMA)
> + * @avg: Average structure
> + * @val: Current value
> + *
> + * Add a sample to the average.
> + */
> +struct ewma*
> +ewma_add(struct ewma *avg, const unsigned int val)
> +{
> + avg->internal = avg->internal ?
> + (((avg->internal * (avg->weight - 1)) +
> + (val * avg->factor)) / avg->weight) :
> + (val * avg->factor);
> + return avg;
> +}
> +EXPORT_SYMBOL(ewma_add);

How can it be a weighted avg if each sample has the same weight?


\
 
 \ /
  Last update: 2010-10-20 17:07    [W:0.057 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site