This topic is just about some examples of table manipulation. There are several types of operations that can be done. If anyone wants to add some types is very welcome to post here. This is a simple example of a linear table with internal range and made with a certain amount of repetitions:
Flatten[Table[Table[n1, {n1, 11, 19}], 3]]
![]()
Below is an example of a table with only one interval and quantity control, both external to the command, as well as some manipulations such as: organization, order, quantity numbers of each type, random permutation, and random choice.
-
Table manipulation with external interval and quantity controlled.
interval = {11, 19}; (*= interval of numbers *) quantity = 3; (*= quantity of each number *) r = RandomSample[ rx = Flatten[ Table[Table[ i, {i, FromDigits[Drop[interval, -1]], FromDigits[Drop[interval, 1]]}], quantity]]]; rx Flatten[Gather[rx]] Sort[rx, Greater] Counts[rx] r {{{RandomChoice[r]}}, N[100*quantity/Count[r, _], 4]} (* Out[1]= raw table *) (* Out[2]= table with gathered elements *) (* Out[3]= sorted table in reverse order *) (* Out[4]= quantity of each number *) (* Out[5]= random permutation *) (* Out[6]= {random pick, % probability} *)
Now a similar type of table but with multiple ranges outside the command and only one quantity control:
-
Table manipulation with multiple external intervals and quantity controlled.
intervals = {{7, 9}, {2, 5}, {19, 20}, {15, 17}}; (*= multiple intervals *) quantities = 2; (*= quantity of each number *) r2 = RandomSample[ r1 = Flatten[ Table[Table[ Table[a, {a, FromDigits[Drop[FromDigits[Take[intervals, {b}]], -1]], FromDigits[Drop[FromDigits[Take[intervals, {b}]], 1]]}], {b, 1, Count[intervals, _]}], quantities]]]; r1 Flatten[Gather[r1]] Sort[r1] Counts[r1] r2 {{{RandomChoice[r2]}}, N[100*quantities/Count[r2, _], 4]} (* Out[1]= raw table *) (* Out[2]= table with gathered elements *) (* Out[3]= sorted table *) (* Out[4]= quantity of each number *) (* Out[5]= random permutation *) (* Out[6]= {random pick, % probability} *)
ListPlot[r1] (* before random permutation *)
ListPlot[r2] (* after random permutation *)
Below is another type of table, but with multiple external intervals and quantities of each interval controlled separately as well as some other variations of manipulations:
-
Table manipulation with multiple external intervals and multiple quantities controlled.
intervals2 = {{5, 7}, {35, 36}, {2, 3}, {51, 54}, {15, 17}}; (*= multiple intervals *) quantities2 = {3, 4, 2, 1, 3}; (*= quantity of each number for each interval *) r22 = RandomSample[ r21 = Flatten[ Table[Table[ Table[l, {l, FromDigits[Drop[FromDigits[Take[intervals2, {m}]], -1]], FromDigits[Drop[FromDigits[Take[intervals2, {m}]], 1]]}], FromDigits[Take[quantities2, {m}]]], {m, 1, Count[quantities2, _]}]]]; r21 Flatten[Gather[r21]] AlphabeticSort[IntegerName[r21]] Counts[r21] r22 z = RandomChoice[r22]; {{{z}}, N[Count[r21, BlockRandom[z]]*100/Count[r21, _], 4]} (* Out[1]= raw table *) (* Out[2]= table with gathered elements *) (* Out[3]= sorted table by alphabetic order *) (* Out[4]= quantity of each number *) (* Out[5]= random permutation *) (* Out[6]= {random pick, % probability} *)
ListPlot[r21] (* before random permutation *)
ListPlot[r22] (* after random permutation *)
These are just a few examples, the ones I know, and if there are other ways or types of manipulation I’d love to know. That topic is about that.
Thanks.














