stirling2
- :
s =stirling2(n, k)¶ Stirling numbers of the second kind.
stirling2 (N, K)returns the number of ways to partition a set of n objects into exactly k non-empty unlabeled subsets. Both n and k must be real non-negative integer scalars. The result is0when k > n (except S(0,0) = 1).Output class follows
nchoosek:doubleby default,singleif either argument is single, or the common integer class when both arguments share one.Behaviour note (MATLAB R2026a):
stirling1/stirling2are not shipped by MathWorks in R2026a. Values match the classical combinatorial table (stirling2 (4, 2) == 7,stirling2 (5, 2) == 15).