[Tutor] Aaagh! Stack arrays!?! calc average

John Washakie washakie at gmail.com
Tue May 1 22:53:15 CEST 2007

It aint pretty! And if I had just walked away, it probably would've
taken half the time in the morning, but here's what I've come up with
(any suggestions for improvements, or course are welcome):

    for d in data:
        w = len(d)
        if d[0] <= tinit+60:
            d = column_stack(d)
            cnt,sum = cnt+1,sum+d

            avg = sum/(ones(w)*cnt)
            tinit,cnt,sum = d[0],0,zeros(n)
            if init==0:
                newData,init = avg,1
                newData = append(newData,avg,axis=0)

    return newData

More information about the Tutor mailing list