# [rrd-users] Re: "Smoothing" a graph

Andres Kroonmaa andre at online.ee
Sat Feb 10 01:07:29 MET 2001

```
Hi,

I've just tried to implement a "moving average" with graph, and it
seems to work pretty nicely. I got the idea from how cisco is doing

This allows you to smooth spikes on graphs, fill in gaps in missing
By playing with weight factor you can nearly any "smoothness" desired.

(hope I just didn't reinvent a wheel ;)

new-mavg = ( (last-mavg - datasample) * weight + datasample

weight=0.983
rrdtool graph \$png -a PNG \
-h 400 \
-w 1000 \
--alt-y-grid  \
--base 1000 \
-s -7week     \
DEF:max=\$rrdfile:ds1:MAX     \
CDEF:inp2=max,UN,1,max,IF      \
CDEF:mavg=PREV,UN,inp2,PREV,IF,inp2,-,\$weight,*,inp2,+      \
"LINE1:inp2#FF0000:Max values\n"       \
"LINE3:mavg#0000FF:Moving average, weight \$weight"

>     From: Phil Henningsen <PhilH at astrology.com>
>
>   I have an RRDatabase that saves five ABSOLUTE variables (MIN, MAX &
>   AVERAGE) with readings taken at 5 minute intervals.  Two of the variables
>   are "sparse and bunched".  For example, the 6 readings over 30 minutes
>   might look like: 0, 10, 0, 12, 2, 8.
>
>   This causes the "two day" chart (where the horizontal grid lines are 1 hour
>   apart) to look like a seismograph during an earthquake.  That is, the lines
>   are very jagged over a wide range.
>
>   Is there any way, while graphing, that I can use an average "as if" it were
>   sampled over a longer interval, thereby smoothing the graph?  That is, in
>   the example above, the total over 30 minutes is 32, and I would like the
>   graph to treat it as if each of the 6 readings were 5.333 or at a rate of
>   1.0666 per minute.
>
>   If I look at a two day interval way back in history, say 6 months ago, the
>   charts have the "smoothed" effect that I would like to achieve in the
>   current period.
>

------------------------------------
Andres Kroonmaa <andre at online.ee>
Delfi Online
Tel: 6501 731, Fax: 6501 708
Pärnu mnt. 158, Tallinn,
11317 Estonia

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users