Search code examples
pythonnumpyrandomprobabilitydice

How to use np.random.randint() to roll n dice, noting that each has a potentially different number of faces denoted by a vector f


I am trying to simulate the single roll of n dice, where each of the die can potentially have f faces. For example, if 𝑓=[2,5,7], then three dice with 2, 5 and 7 faces are rolled. Thank you!


Solution

  • I got it to work with this:

        f=[3,4,5]
        outcomes= []
        for i in f:
            out = 1 + np.random.randint(i, size = len(f) )
            outcomes.append(out)
    

    Thank you!