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