def sampleYes(array, N):
"""Sample without replacement N points from an array of XY coordinates.
Args:
array: 2D numpy array of XY points.
N: Integer number of points to sample without replacement from
input array.
Returns:
Tuple of (sampled points, unsampled points).
"""
# array is a Mx2 array of X,Y points
m, n = array.shape
allidx = np.arange(0, m)
sampleidx = np.random.choice(allidx, size=N, replace=False)
nosampleidx = np.setxor1d(allidx, sampleidx)
sampled = array[sampleidx, :]
notsampled = array[nosampleidx, :]
return (sampled, notsampled)
评论列表
文章目录