Counting the number of a specific type of permutation

If I'm not mistaken, we can do this in closed form. Suppose we have $n$ indices split up into $n_1$ one-index variables, $n_2$ two-index variables, etc. Then the total number of distinct permutations is just $N=\dfrac{n!}{\prod\limits_{i}n_i!(i!)^{n_i}}$.

This accounts for the $n_i!$ permutations of $i$-index variables and the $i!$ permutations of each of their indices.

This can be implemented pretty simply. With x being a list of the $n_i$ (including zeros),

numDistinct[x_] :=
  Plus@@(x.Range@Length@x)!/Product[x[[i]]! (i!)^x[[i]], {i, Length@x}]

This yields numDistinct[{2, 1}] = 6 and numDistinct[{0, 3}] = 15, as it should.


Sorry for this seat-of-the-pants approach. I was too rushed to figure out the underlying combinatorics. f produces all the permutations (including equivalent cases), sorts them at Level 2, and then delete duplicates. dynP is by Mr.Wizard.

dynP[l_,p_]:=MapThread[l[[#;;#2]]&,{{0}~Join~Most@#+1,#}&@Accumulate@p]

f[p_]:=DeleteDuplicates[Map[Sort(dynP[#,p]&/@
  Permutations[FromCharacterCode/@Range[97,96+Plus@@p]]),2]]//Length


f /@ {{1, 1, 3}, {2, 2, 2}, {1, 2, 3}, {3, 1, 2}}

{10, 15, 60, 60}

Remove //Length from function to see the permutations.


ClearAll[numtermsF];
numtermsF = Coefficient[MomentConvert[Moment[Total@{##}], Cumulant], 
  Times @@ (Cumulant[#[[1]]]^(#[[2]]) & /@ Tally[{##}])] &
numtermsF @@ # & /@ {{1, 1, 2}, {2, 2, 2}, {1, 1, 3}, {3, 1, 2}, {1, 2, 3}}
(* {6, 15, 10, 60, 60} *)

see also: Documentation Center MomentConvert>Applications>Combinatorial Uses of MomentConvert