I have a sorted numpy array
X
k
delta
X
X
k
delta
k
max {i  k  delta <= X[i] <= k } (1)
None
X
# Get the max from the set of indices in X satisfying (1)
idx = np.where((kdelta <= X) * (X <= k))[0].max()
X
(kdelta <= X) * (X <= k))
.max()
One efficient approach to leverage the sorted order would be with np.searchsorted

def largest_within_delta(X, k, delta):
right_idx = X.searchsorted(k,'right')1
if (k  X[right_idx]) <= delta:
return right_idx
else:
return None
Sample runs to cover various scenarios 
In [216]: X
Out[216]: array([ 8, 9, 33, 35, 36, 37, 44, 45, 71, 81])
In [217]: largest_within_delta(X, 36, 0) # this k is already in array
Out[217]: 4
In [218]: largest_within_delta(X, 36, 1) # shouldn't choose for next one 37
Out[218]: 4
In [220]: largest_within_delta(X, 40, 3) # Gets 37's index
Out[220]: 5
In [221]: largest_within_delta(X, 40, 2) # Out of 37's reach
Runtime test
In [212]: # Inputs
...: X = np.unique(np.random.randint(0,1000000,(10000)))
...: k = 50000
...: delta = 100
...:
In [213]: %timeit np.where((kdelta <= X) * (X <= k))[0].max()
10000 loops, best of 3: 44.6 µs per loop
In [214]: %timeit largest_within_delta(X, k, delta)
100000 loops, best of 3: 3.22 µs per loop