Reputation: 477
what is best way to shuffle given matrix in Julia (2d-array)?
Function shuffle() does not work.
What I mean is randomly shuffle rows (not all elements).
Upvotes: 7
Views: 6920
Reputation: 3950
to shuffle all rows of matrix
a = a[shuffle(1:end), :]
for those who mean to shuffle a specific row,
function shuffle_row(mat, row)
mat[row,:] = shuffle(mat[row,:])
end
Upvotes: 11