For an array like this:
import numpy as np
x = np.random.randint(0, 2, (5,5))
How can I replace the ones with tens randomly with 0.3 probability? This is something I tried but I don't know if it is the best method
mask = np.random.rand(5, 5)<0.3
x[x==1 * mask] = 10