dodiscover.ci.monte_carlo.restricted_nbr_permutation#

dodiscover.ci.monte_carlo.restricted_nbr_permutation(nbrs, random_seed=None)[source]#

Compute a permutation of neighbors with restrictions.

Parameters:
nbrsarray_like of shape (n_samples, k)

The k-nearest-neighbors for each sample index.

random_seedint, optional

Random seed, by default None.

Returns:
restricted_permarray_like of shape (n_samples)

The final permutation order of the sample indices. There may be repeating samples. See Notes for details.

Notes

Restricted permutation goes through random samples and looks at the k-nearest neighbors (columns of nbrs) and shuffles the closest neighbor index only if it has not been used to permute another sample. If it has been, then the algorithm looks at the next nearest-neighbor and so on. If all k-nearest neighbors of a sample has been checked, then a random neighbor is chosen. In this manner, the algorithm tries to perform permutation without replacement, but if necessary, will choose a repeating neighbor sample.