Yes, I provide you with a simple method to do the same task. You can use the NumPy np.all() function to select specific rows from a multinomial distribution. Here’s an example code:

In the above code the np.all() function checks if all elements in each row of array X are integers (modulus with 1 is zero) using axis=1. The & operator performs an element-wise “and” operation between boolean arrays obtained from integer and sum checks. Rows of X satisfying both conditions are printed by indexing with the boolean array M.