jeudi 6 mai 2021

order a sequence based on the sum of the window values

I know the question is not very clear so I try to make a clearer example: I have some values, which represent the minute of the day and a corresponding value, like

import numpy as np
x = np.arange(1440)
values = np.sin(2*np.pi/1440*2*l - np.pi/2)+1

and I want to get the ordered (from lower to larger) sums per hour of values, where I don't want any value to be excluded, except at least the highest remaining ones, so in this case I would get 24 ordered (my hours) values, or better 23 if I consider that the minimum sum could be anywhere in the series and in the end I will have some values at the end and the beginning whose 'window will be less than 60 minutes, except in a very particular case.

I don't know if I should apply a boolean mask in a while loop which I could manage to do or if numpy or some other packets have already some functions that could help me in solving the problem. Thanks

Also, if possible, I would like to get the SORTED NONSUBSQUENT SUMS, up to the moment where I have no more intervals of the right (WINDOW) length, which in this particular case implies that my results will have a minimum of 12 windows sums up to 24. Thanks again

So, in a general case (I have no space to insert the minute data) if my values are: [1,2,3,4,5,6,0,0,0,7,8,9] and I will need to group them in windows of 3 elements size (in the real case this is my 60 minutes window), my result will be: [[0,0,0],[1,2,3],[4,5,6],[7,8,9]].

Or to be more general,if they are: [0,1,2,3,4,5,6,0,0,0,7,9,1,9,6], in the first case I would get: [[0,0,0],[1,2,3],[4,5,6],[7,9,1]] (because I take subsequent windows) and in the second case I would get: [[0,0,0],[0,1,2],[3,4,5],[1,9,6]] (because I just focus on the minimum sorted sums)

Aucun commentaire:

Enregistrer un commentaire