Better way to shuffle two numpy arrays in unison

I have two numpy arrays of different shapes, but with the same length (leading dimension). I want to shuffle each of them, such that corresponding elements continue to correspond — i.e. shuffle them in unison with respect to their leading indices. This code works, and illustrates my goals: def shuffle_in_unison(a, b): assert len(a) == len(b) … Read more

Random shuffling of an array

Using Collections to shuffle an array of primitive types is a bit of an overkill… It is simple enough to implement the function yourself, using for example the Fisher–Yates shuffle: import java.util.*; import java.util.concurrent.ThreadLocalRandom; class Test { public static void main(String args[]) { int[] solutionArray = { 1, 2, 3, 4, 5, 6, 16, 15, 14, … Read more