(X, n_perm=None, metric="euclidean")
return idx_perm, lambdas, dperm2all
Compute a furthest point sampling permutation of a set of points

    Parameters
    ----------
    X: ndarray (n_samples, n_features)
        A numpy array of either data or distance matrix

    n_perm: int
        Number of points to take in the permutation

    metric: string or callable
        The metric to use when calculating distance between instances in a
        feature array

    Returns
    -------
    idx_perm: ndarray(n_perm)
        Indices of points in the greedy permutation

    lambdas: ndarray(n_perm)
        Covering radii at different points

    dperm2all: ndarray(n_perm, n_samples)
        Distances from points in the greedy permutation to points
        in the original point set
Compute a furthest point sampling permutation of a set of points
Compute a furthest point sampling permutation of a set of points
def get_greedy_perm(X, n_perm=None, metric="euclidean"):
    """Compute a furthest point sampling permutation of a set of points

    Parameters
    ----------
    X: ndarray (n_samples, n_features)
        A numpy array of either data or distance matrix

    n_perm: int
        Number of points to take in the permutation

    metric: string or callable
        The metric to use when calculating distance between instances in a
        feature array

    Returns
    -------
    idx_perm: ndarray(n_perm)
        Indices of points in the greedy permutation

    lambdas: ndarray(n_perm)
        Covering radii at different points

    dperm2all: ndarray(n_perm, n_samples)
        Distances from points in the greedy permutation to points
        in the original point set

    """
    if not n_perm:
        n_perm = X.shape[0]
    # By default, takes the first point in the list to be the
    # first point in the permutation, but could be random
    idx_perm = np.zeros(n_perm, dtype=np.int64)
    lambdas = np.zeros(n_perm)
    if metric == 'precomputed':
        dpoint2all = lambda i: X[i, :]
    else:
        dpoint2all = lambda i: dpoint2pointcloud(X, i, metric)
    ds = dpoint2all(0)
    dperm2all = [ds]
    for i in range(1, n_perm):
        idx = np.argmax(ds)
        idx_perm[i] = idx
        lambdas[i - 1] = ds[idx]
        dperm2all.append(dpoint2all(idx))
        ds = np.minimum(ds, dperm2all[-1])
    lambdas[-1] = np.max(ds)
    dperm2all = np.array(dperm2all)
    return idx_perm, lambdas, dperm2all
def get_greedy_perm ( X , n_perm = None , metric = "euclidean" ) : if not n_perm : n_perm = X . shape [ 0 ] # By default, takes the first point in the list to be the # first point in the permutation, but could be random idx_perm = np . zeros ( n_perm , dtype = np . int64 ) lambdas = np . zeros ( n_perm ) if metric == 'precomputed' : dpoint2all = lambda i : X [ i , : ] else : dpoint2all = lambda i : dpoint2pointcloud ( X , i , metric ) ds = dpoint2all ( 0 ) dperm2all = [ ds ] for i in range ( 1 , n_perm ) : idx = np . argmax ( ds ) idx_perm [ i ] = idx lambdas [ i - 1 ] = ds [ idx ] dperm2all . append ( dpoint2all ( idx ) ) ds = np . minimum ( ds , dperm2all [ - 1 ] ) lambdas [ - 1 ] = np . max ( ds ) dperm2all = np . array ( dperm2all ) return idx_perm , lambdas , dperm2all