Search code examples
pythontensorflowdicetensorflow-probability

Probability mass function sum 2 dice roll?


Triying to plot pmf for 2 dice sum, but some tail-right problems occur.

I have tried using numpy and other python libraries and the problems stays:

import tensorflow as tf
tf.enable_eager_execution()
import tensorflow_probability as tfp
from matplotlib import pyplot as plt
import numpy as np

a=500000
dado1_=evaluate(tf.cast(tfp.distributions.Uniform(low=1,high=7).sample(a),tf.int32))
dado2_=evaluate(tf.cast(tfp.distributions.Uniform(low=1,high=7).sample(a),tf.int32))

plt.hist(np.add(dado1_,dado2_))
expecting symetric distribution centered at 7 with gaussian form,
assymetric found

outputplot


Solution

  • Looking at the graph, it seems like the area between the tick mark for 2 and 3 is the number of rolls that sum to 2. 3-4 is 3, and so on.

    Is it possible that between tick marks 11 and 12 contains the number of rolls that sum to 11 and 12? It could explain why the graph seems shorter on the right side than it should be, as well as why the last bar is taller than expected.