dimanche 24 juillet 2022

Is there any way to shuffle rows of a matrix without changing the frequency of each column?

I have an NxR random matrix which has in each row shuffled 1:R. I need another matrix with different sorts of shuffling in each row to have the same distribution of 1 to R for each column. In other words, is there any way to shuffle rows of a matrix while keeping the frequency of each column the same?

I attached a screenshot of matrix B which I generated manually based on Matrix A. SS of matrix A and B

Both have 1 to 4 in each row and the distribution of columns of A matches with columns of B. For example, in the first column of both matrices, there are two 1s, four 2s, one 3, and three 4s.

Is there any way to write an algorithm to generate the matrix B for larger dimensions?




Aucun commentaire:

Enregistrer un commentaire