On 2009-05-22 08:50, Scott David Daniels wrote:
Yash Ganthe wrote:
I would like to shrink a large list in the following way:
If the List has 1000 integers, we need only 100 averages such that the
1000 points are average for every 10 consecutive values. So p0 to p9
will be averaged to obtain t0. p10 to p19 will be averaged to obtain
t1 and so on. This is a 10-point mean.

We are doing this as we collect a lot of data and plot it on a graph.
Too many samples makes the graph cluttered. So we need to reduce the
number of values in the way described above.

Does this give you a clue?

import numpy as np

v = np.arange(128)
v.shape = (16, 8)
sum(v.transpose()) / 8.

Or even:

import numpy as np

v = np.arange(1000).reshape((-1, 10))
ten_point_mean = v.mean(axis=1)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to