design.py 文件源码

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

项目:GPflowOpt 作者: GPflow 项目源码 文件源码
def _shrink(X, npoints):
        """
        When designs are generated that are larger than the requested number of points (N* > N), resize them.
        If the size was correct all along, the LHD is returned unchanged.

        :param X: Generated LHD, size N* x D, with N* >= N
        :param npoints: What size to resize to (N)
        :return: LHD data matrix, size N x D
        """
        npStar, nv = X.shape

        # Pick N samples nearest to centre of X
        centre = npStar * np.ones((1, nv)) / 2.
        distances = cdist(X, centre).ravel()
        idx = np.argsort(distances)
        X = X[idx[:npoints], :]

        # Translate to origin
        X -= np.min(X, axis=0) - 1

        # Collapse gaps in the design to assure all cell projections onto axes have 1 sample
        Xs = np.argsort(X, axis=0)
        X[Xs, np.arange(nv)] = np.tile(np.arange(1, npoints + 1), (nv, 1)).T
        assert (X.shape[0] == npoints)
        return X
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号