dimanche 25 octobre 2020

Is there an efficient way to generate multinomial random variables in parallel?

numpy.random has the following function to generate multinomial random samples.

multinomial(n, p, size)

But I wonder if there is an efficient way to generate multinomial samples for different parameters n and p. For example,

n = np.array([[10],
             [20]])
p = np.array([[0.1, 0.2, 0.7],
             [0.4, 0.4, 0.2]])

and even for higher dimension n and p like these:

n = np.array([[[10],
        [20]],
       [[10],
        [20]]])
p = np.array([[[0.1, 0.2, 0.7],
        [0.1, 0.2, 0.7]],
       [[0.3, 0.2, 0.5],
        [0.4, 0.1, 0.5]]])

I know for the univariate random variable, we can do this kind of things, but don't know how to do it for multinomial in python.




Aucun commentaire:

Enregistrer un commentaire