You can use index swapping.
You a have two array a and b
def swap_random(a, b):
"""Randomly swap entries in two arrays."""
# Indices to swap
swap_inds = np.random.random(size=len(a)) < 0.5 # your threshold
# Make copies of arrays a and b for output
a_out = np.copy(a)
b_out = np.copy(b)
# Swap values
a_out[swap_inds] = b[swap_inds]
b_out[swap_inds] = a[swap_inds]
return a_out, b_out
So, do the test
d = np.array(range(0,15))
r = np.array(range(16,31))
display(d,r)
>>> array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
>>> array([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])
display(swap_random(d, r))
>>> (array([ 0, 17, 2, 3, 20, 21, 22, 7, 24, 25, 10, 11, 28, 13, 14]),
>>> array([16, 1, 18, 19, 4, 5, 6, 23, 8, 9, 26, 27, 12, 29, 30]))