Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia - how to shuffle matrix

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).

like image 211
gugatr0n1c Avatar asked Nov 25 '16 11:11

gugatr0n1c


Video Answer


1 Answers

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 
like image 137
isebarn Avatar answered Oct 03 '22 22:10

isebarn