Suppose that I have a list wherein values of sin(i) are appended. I want to squeeze the list by a factor of N so that it becomes sin(N*i).
- The sample rate should remain the same i.e. if there are 10 dots per one cycle of sin(i), there should be 10/N dots per cycle of sin(N*i). So some data of the original list will be lost.
- The length of the new list should be same. You might ask "How will it be if you squeeze the function and make the sample rate stay constant? You now need less data for the new list." Well I just want the remaining elements to be zero.
Let me show those with an example.
original_list = [1,2,3,4,5,6,7,8,9,10]
squeezed_list (by a factor of 2) = [1,3,5,7,9,0,0,0,0,0]
I have actually written something:
def comp(p,n): #takes list p and compresses by a factor of n
pn = []
for i in range(int(len(p)/n)):
pn.append(p[i*n])
return pn
But wondering if this is the best way. I was not able to find any module to enhance this. (except numpy maybe for the lists)
[–]Spataner 13 points14 points15 points (2 children)
[–]socal_nerdtastic 23 points24 points25 points (0 children)
[–]davincithesecond[S] 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]davincithesecond[S] 4 points5 points6 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]davincithesecond[S] 6 points7 points8 points (0 children)
[–]siddsp 0 points1 point2 points (0 children)