maths.monte_carlo_dice

Classes

Dice

Functions

throw_dice(→ list[float])

Return probability list of all possible sums when throwing dice.

Module Contents

class maths.monte_carlo_dice.Dice
roll()
NUM_SIDES = 6
sides
maths.monte_carlo_dice.throw_dice(num_throws: int, num_dice: int = 2) list[float]

Return probability list of all possible sums when throwing dice.

>>> random.seed(0)
>>> throw_dice(10, 1)
[10.0, 0.0, 30.0, 50.0, 10.0, 0.0]
>>> throw_dice(100, 1)
[19.0, 17.0, 17.0, 11.0, 23.0, 13.0]
>>> throw_dice(1000, 1)
[18.8, 15.5, 16.3, 17.6, 14.2, 17.6]
>>> throw_dice(10000, 1)
[16.35, 16.89, 16.93, 16.6, 16.52, 16.71]
>>> throw_dice(10000, 2)
[2.74, 5.6, 7.99, 11.26, 13.92, 16.7, 14.44, 10.63, 8.05, 5.92, 2.75]