## Multinomial Theorem Formula

$$\sum_{k_1 + \cdots +k_m =n} \frac{n!}{k_1!\cdots k_m!}. (k_1 + 1).(k_2 + 1)\cdots(k_m + 1)$$

I read about Multinomial Theorem, this one looks similar to it, are there any ways to calculate this in a easier way. Can this be further generalised?

## Improving speed of Binomial and Multinomial Random Draws

A number of users have discussed the speed of Random number generation in Mathematica.

The Binomial and Multinomial random number generators in Mathematica are fast if multiple draws are needed for the same distribution parameters. For example, generating 500000 draws from the Binomial distribution is very quick

In[30]:= AbsoluteTiming[  RandomVariate[BinomialDistribution[100, 0.6], 500000];]  Out[30]= {0.017365, Null} 

However, the speed is slow compared to that in R and Julia when the parameters change across draws, as may be required when performing certain Monte Carlo simulations.

For example, if we have a vector nvec that contains the number of trials for each draw and a vector pvec that contains the corresponding probabilities of success.

nvec = RandomInteger[{5, 125}, 500000];  pvec = RandomReal[{0, 1}, 500000]; 

Then we have

In[28]:= AbsoluteTiming[  Mean[Table[     RandomVariate[BinomialDistribution[nvec[[i]], pvec[[i]]]], {i, 1,       Length@nvec}]] // N  ]  Out[28]= {36.2144, 32.5283} 

This hit in speed most probably stems from how these are implemented internally in Mathematica.

Are there alternate methods that are fast for the case when the parameter distribution changes across the draws?

## How to do validation for calibrated multinomial logit model and glmer(generalized linear mixed effect) model using new data in R?

Once I have an estimated or calibrated multinomial logit and glmer models, I need to see how the model is strong in its prediction capabilities by observing and checking the whole capacity of calibrated model. How can I measure or handle it using new data in R? what kind of packages will be employed in R to see the prediction probabilities, standard errors, residuals….etc? Any help is appreciated. Thank you.