如果有M个不同的盒子和N个相同的球
我们需要把这些球放进盒子里。
州中的州可能有多少个?
这是计算机模拟谜题的一部分。我几乎忘记了所有的数学知识。
and we need to put these balls into boxes.
How many states of the states could there be?
This is part of a computer simulation puzzle. I've almost forget all my math knowledges.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您正在寻找多项系数。
我会检查自己并扩展我的答案。
编辑:
如果您查看我提供链接的维基百科文章,您可以看到您在问题中定义的
M
和N
对应于m< /code> 和
n
在 Theorem 部分中定义。这意味着您的问题对应于:“将多项式展开为任意幂时可能的系数排序数是多少?”,其中
N
是幂,并且M
是多项式中变量的数量。换句话说:
您要寻找的是对
M
变量多项式的多项系数求和,该多项式在求N
次方时展开。确切的方程有点长,但维基百科上解释得非常清楚。
为什么这是真的:
多项式系数为您提供了当分组为特定分组时在篮子之间排序相同球的方法数(例如,4 个球分为 3、1 和 1 - 在本例中 M=4 和 N=3)。对所有分组选项求和时,您将获得所有可能的组合。
我希望这对你有帮助。
I believe you are looking for the Multinomial Coefficient.
I will check myself and expand my answer.
Edit:
If you take a look at the wikipedia article I gave a link to, you can see that the
M
andN
you defined in your question correspond to them
andn
defined in the Theorem section.This means that your question corresponds to: "What is the number of possible coefficient orderings when expanding a polynomial raised to an arbitrary power?", where
N
is the power, andM
is the number of variables in the polynomial.In other words:
What you are looking for is to sum over the multinomial coefficients of a polynomial of
M
variables expanded when raised to the power onN
.The exact equations are a bit long, but they are explained very clearly in wikipedia.
Why is this true:
The multinomial coefficient gives you the number of ways to order identical balls between baskets when grouped into a specific grouping (for example, 4 balls grouped into 3, 1, and 1 - in this case M=4 and N=3). When summing over all grouping options you get all possible combinations.
I hope this helped you out.
这些注释一般解释了如何解决“盒子里的球”问题:球是否是否贴有标签、盒子是否贴有标签、每个盒子中是否必须至少有一个球等。
These notes explain how to solve the "balls in boxes" problem in general: whether the balls are labeled or not, whether the boxes are labeled or not, whether you have to have at least one ball in each box, etc.
这是一个基本的组合问题(将相同的对象分配到不同的槽中)
状态数为[(N+M-1)选择(M-1)]
this is a basic combinatorial question (distribution of identical objects into non identical slots)
the number of states is [(N+M-1) choose (M-1)]