I made code that calculates the average value for each element in period p for array y
import numpy as np
p=4
y =np.asarray([146, 96, 59, 133, 192, 127, 79, 186, 272, 155, 98, 219])
c=len(y)/p
print c
a=[]
for i in range(1,c+1):
s=y[p*(i-1):p*i]/np.mean(y[p*(i-1):p*i])
a = np.append(a, s)
print a
b=[]
for i in range(c+1):
s = np.mean(a[i::p])
b = np.append(b, s)
print b
Is there a more efficient way to do this instead of using append and the for loops? I do not need both arrays just b
range(p), as you iterate modulo p:a[i::p]. I updated answer, last result equals your expected b, but is one item longer, since c=3 but p=4.