import numpy as np
original_array = np.array([[1,2,3],[4,5,6],[7,8,9]])
permuted_rows = np.random.permutation(original_array)
permuted_columns = np.random.permutation(original_array.T).T
print("original array:")
print(original_array)
print("permuted rows:")
print(permuted_rows)
print("permuted columns:")
print(permuted_columns)

Output:

original array:
[[1 2 3]
 [4 5 6]
 [7 8 9]]
permuted rows:
[[4 5 6]
 [1 2 3]
 [7 8 9]]
permuted columns:
[[2 1 3]
 [5 4 6]
 [8 7 9]]

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading