I have some points in the interval [0,20]
I have a window of size window_size=3 that I can move inside the above interval. Therefore the beginning of the window - let's call start is constrained to [0,17].
Let's say we have some points below:
points = [1.4,1.8, 11.3,11.8,12.3,13.2, 18.2,18.3,18.4,18.5]
If we wanted a minimum of min_points=4 points the solution of the start ranges of the windows (which I found manually ) are:
suitable_starts = [[10.2,11.3],[15.5,17.0]]
i.e. The start of the size 3 window can be from 10.2 to 11.3 and from 15.5 to 17.0. Trivially, the corresponding end of the windows would just be +3 of the start ranges.
I am looking for a way to algorithmically cover this quickly with clever numpy or scipy or other functionality.
The general function I'm looking for is:
get_start_windows(interval = [0,20],
window_size = 3.0,
points = [1.4,1.8,11.3,11.8,12.3,13.2,18.2,18.3,18.4,18.5],
min_points = 4
return suitable_starts # suitable_starts = [[10.2,11.3],[15.5,17.0]]
Note:
As someone in the comments has pointed out there are special cases sometimes when points are exactly window_size apart. However in reality the points are double floats where it is impossible for them to exactly window_size apart so these can be ignored.
These special examples include:
points = [1.4,1.8, 11.3,11.8,12.3,13.2,14.2,15.2,16.2,17.2,18.2,18.3,18.4,18.5]
but these can be safely ignored.