# [Tutor] Newbie Here -- Averaging & Adding Madness Over a Given (x) Range?!?!

Michael J. McConachie michael at redhat.com
Fri Feb 15 23:00:55 CET 2013

```On 02/15/2013 04:03 PM, Albert-Jan Roskam wrote:
> <snip>
>> Eventually what I'll need to do is:
>> 1.  Index the file and/or count the lines, as to identify each line's
>> positional relevance so that it can average any range of numbers that are
>> sequential; one to one another.
> In other words: you would like to down-sample your data? For example, reduce a sampling frequency from 1000 samples/second (1KHz) to 100, by averaging every ten sequential data points?
I think so.  When I said 'index' in my OP, I wasn't sure how to explain
that each line would be used positionally to identify each group of (x)
among themselves.  (That's all I meant.)  I am trying to identify
gradient(s) in order to determine performance 'thresholds' if they
exist.  We are noting that as the number of tasks (already performed)
increases, a noticeable decrease in the performance of a certain
repeated task exists.  I am trying to determine that point/elbow in the
performance curve.  I have been asked to identify, and plot the overall
'average performance' with varying levels of granularity.  (Averaging
10, by 100, by 1000, etc.)

The file I mentioned in my OP contains the measurement of time it takes
to complete these repeated tasks.  Each entry is on it's own line. The
recorded data is in literal order of completion.  I am averaging those
(ms time entries) in sets of (x) to keep from having to compute the
difference in time for each completed task individually.

ie:
Lines 1-10, (11-20, 21-30 --> to completion) are averaged and
read into a list, or hash in order.
or:
Lines 1-100, (101-200, 201-300 --> to completion) are averaged
and read into a list, or hash in order.
or:
Lines 1-1000, (1001-2000, 2001-3000 --> to completion) are
averaged and read into a list, or hash in order.

etc, etc.
>> 2.  Calculate the difference between any given (x) range.  In order to be able
>> to ask the program to average every 5, 10, 100, 100, or 10,000 etc. --> until
>> completion.  This includes the need to dealing with stray remainders at the end
>> of the file that aren't divisible by that initial requested range.
> In other words: you would like to calculate a running/moving average, with window size as a parameter?
Yes.

```