Efficient Matlab implementation of Multinomial Coefficient

后端 未结 4 844
栀梦
栀梦 2021-02-11 07:35

I want to calculate the multinomial coefficient:

\"enter

where it is satisifed

4条回答
  •  爱一瞬间的悲伤
    2021-02-11 07:52

    Sorry to resurrect an old post, but for future searchers, you should almost certainly just write your multinomial coefficient as a product of binomial coefficients and use a built-in method to compute binomial coefficients (or write your own, either using Pascal's triangle or another method). The relevant formula appears in the first paragraph of the Wikipedia section on multinomial coefficients. (I'd write it here, but there doesn't seem to be a way to render LaTeX.)

    Another benefit of this approach is that it's as good as you can possibly get about overflow since the factors are all integers. There's no intrinsic need to divide when computing multinomial coefficients.

提交回复
热议问题