This two-dimensional example of samples uniformly on two dimensions, selects each point with a constant probability (thus preserving the doubly distributed number of points), randomly selects and does not replace these points from the sampling space and generates a pair of vectors that you can go to your function f :
import numpy as np
import random
resolution = 10
keepprob = 0.5
min1, max1 = 0., 1.
min2, max2 = 3., 11.
keepnumber = np.random.binomial(resolution * resolution, keepprob,1)
array1,array2 = np.meshgrid(np.linspace(min1,max1,resolution),np.linspace(min2,max2,resolution))
randominixes = random.sample(list(range(resolution * resolution)), int(keepnumber))
randominixes.sort()
vec1Sampled,vec2Sampled = array1.flatten()[randominixes],array2.flatten()[randominixes]
source
share