Im trying to accomplish a Vectoriced Numpy version of itertools.combinations, that I futher can decorate with @jit (Numba) - To make it even faster. (I am not sure if this even can be done)
The dataset im working on is a 1d - np.array, the goal is to get combinations with set of 3.
x = np.array([1,2,3,4,5])
set(combinations(x, 3))
Result:
{(1, 2, 3),
(1, 2, 4),
(1, 2, 5),
(1, 3, 4),
(1, 3, 5),
(1, 4, 5),
(2, 3, 4),
(2, 3, 5),
(2, 4, 5),
(3, 4, 5)}
I have been searching stack & other resources, I did find quite alot info on this topic, but not any usefull info in regards to my usecase.
N-D version of itertools.combinations in numpy
This thread indicates that it probably are quite hard to get anything faster than itertools.combinations:
numba-safe version of itertools.combinations?
I was asked to specify the usecase a bit more:
I have a price data np.array price= ([100,101,102,103,104,105 etc..])
I use scipy.signal.argrelmax to find all peaks in the array. (red dots in above pic.)
I will now need to get all combinations of the peaks.
Then I will run simple linear regression over all combination, and look for a certain r_val treshold, to verify a trendline.(green dot in above picture)
(The combination of 3 is because then I know the trendline had 3 touches. On illustration I have posted it is 4 touches, so I work with both 3 or 4 touches.)
(futhermore I use integrals above / below trendline to filter)
I do not need the combi func. to return a set of tuples, the simple linear regression algo I have written, is optimized to numpy.