spiketools.utils.data.permute_vector

spiketools.utils.data.permute_vector(data, n_permutations=1000)[source]

Create permutations of a vector of data.

Parameters:
data1d array

Vector to permute.

n_permutationsint, optional, default: 1000

Number of permutations to do.

Returns:
permutations2d array

Permutations of the input data.

Notes

Code adapted from here: https://stackoverflow.com/questions/46859304/

This function doesn’t have any randomness - for a given array it will iterate through the same set of permutations, in sequence.

Examples

Create permutations for a vector of data:

>>> data = np.array([0, 5, 10, 15, 20])
>>> permute_vector(data, n_permutations=4)
array([[ 0,  5, 10, 15, 20],
       [ 5, 10, 15, 20,  0],
       [10, 15, 20,  0,  5],
       [15, 20,  0,  5, 10]])