# Histogram3D for Dice Rolls

I am trying to graph a 3D histogram for a dice roll with 3 outcomes. The first set I have either 1, 2, or 3 with the same probabilities. (0.33)

The second time 1, and 2 have 0.25 chance and 3 has 0.5 chance of happening.

I want to make a 3D histogram that shows the probability density of different outcomes. Since 4d plot is not possible one set could be removed (eg. for n3).

• it is unclear what the plot is supposed to be. What are the plot axes? You make no other mention of n so whats it supposed to mean to "remove" n3 ? Commented Sep 26, 2016 at 15:49

To plot the histogram, we need to generate couples describing an event: $(roll 1,roll2)$

An easy way to do this is to use RandomChoice with the appropriate weight. Since both events are independent, we can just generate them separately and merge the two lists together.

With[{n = 1000},
Histogram3D[
Transpose[{RandomChoice[{1/3, 1/3, 1/3} -> {1, 2, 3},n],
RandomChoice[{0.25, 0.25, 0.5} -> {1, 2, 3},n]}],
Automatic, "Probability"]
]


• note you can give n directly as an argument to RandomChoice instead of using Table Commented Sep 26, 2016 at 15:45
• Good catch! I've edited it in since it improves the readability of the code. Commented Sep 26, 2016 at 16:54