# Appropriate syntax for constructing frequency table and histogram from experiment with three or more dice?

if I say to input 3, how do I get MMA to make me a table with all the cases on the left, in the center their frequency and on the right a histogram,bar chart, or some other way to represent the above. Thanks in advance

t = Input["Give Sum"];
Select[Tuples[Range[6], 3], Total[#] >= t &]


Edited something like this I need or similar

• All the outcomes given by your second line has the same probability. Do you want to ignore the order of throws? sorted = Sort /@ list; outcomes = Sort@(StringJoin[ToString /@ #] & /@ sorted) Commented Aug 22, 2021 at 0:18
• @Domen.thanks for the answer, if I want them to be only combinations, it doesn't matter the order. could you put the complete code , when I implement it I get this error "Sort::normal: Nonatomic expression expected at position 1 in Sort[list]. Commented Aug 22, 2021 at 0:43
• GroupBy[Tuples[Range[6], 3], Total] may get you started. Commented Aug 22, 2021 at 5:23

data = KeySort@GroupBy[Tuples[Range[6], 3], Total]
(*    <|3 -> {{1, 1, 1}},
4 -> {{1, 1, 2}, {1, 2, 1}, {2, 1, 1}},
...
17 -> {{5, 6, 6}, {6, 5, 6}, {6, 6, 5}},
18 -> {{6, 6, 6}}|>                         *)

MatrixForm[Prepend[
KeyValueMap[{#2, #1, Length[#2]} &, data],
{"cases", "sum", "frequency"}]]

(*    cases                               sum   frequency
{{1, 1, 1}}                           3           1
{{1, 1, 2}, {1, 2, 1}, {2, 1, 1}}     4           3
...
{{5, 6, 6}, {6, 5, 6}, {6, 6, 5}}    17           3
{{6, 6, 6}}                          18           1    *)

ListPlot[KeyValueMap[{#1, Length[#2]} &, data], Filling -> Axis]


• thank you very much, just what I needed Commented Aug 22, 2021 at 20:10