sample.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:groundfailure 作者: usgs 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号