I need to do something like this
import numpy as np a = np.random.rand(1000) a -= .55 a[0] = 1 b = 0 for i in range(len(a)): b += a[i] if b < 0: print(i) break a lot, and preferably it should be swift. Can NumPy help me with that? I understand that NumPy is built for vector calculation and not for this. Still, it can calculate the sum of an array blazingly fast - can I give it this specific condition (the sum is negative for the first time) to stop and tell me the index number?