I am trying to make a computation with a large set of rows. As a sample, suppose I have a list of numbers with rows and columns like such:
A =
4 1 3 1 3
2 3 2 4 1
2 2 4 3 2
3 2 4 3 2
1 2 4 2 3
4 1 3 2 2
2 2 2 1 2
2 1 2 4 3
1 3 2 1 1
3 4 3 3 4
3 1 4 2 2
In Mathematica code this would look like
A = {{4, 1, 3, 1, 3}, {2, 3, 2, 4, 1}, {2, 2, 4, 3, 2}, {3, 2, 4, 3, 2},
{1, 2, 4, 2, 3}, {4, 1, 3, 2, 2}, {2, 2, 2, 1, 2}, {2, 1, 2, 4, 3},
{1, 3, 2, 1, 1}, {3, 4, 3, 3, 4}, {3, 1, 4, 2, 2}}
I would like to create a tally or find the most common row of numbers with the same number of numbers.
Particularly, the order of numbers does not matter. So for example,
4 1 3 1 3
,3 4 1 3 1
,1 1 3 3 4
and any combination of these numbers or set of unordered numbers are all equivalent. I am trying to count how many rows have the number 3 occur 2 times, the number 1 occur 2 times, and the number 4 occur 1 time. In the list A
it appears that this unordered set only occurs once.
Furthermore, the unordered set 3 1 4 2 2
occurs 5 times (If a counted correctly).
I would like to create a tally from the initial list A
which will have the size of n x 5
Any pointers, guidance, or suggestions is greatly appreciated, thank you.
Tally
, but I don't know how to incorporate it given this situation of unordered sets. $\endgroup$CountsBy[A, Sort]
? But this - " I am trying to count how many rows have the number 3 occur 2 times, the number 1 occur 2 times, and the number 4 occur 1 time" is something different, isn't it? $\endgroup$