In the theory of cumulants of vector-valued random variables, the following types of formulas appear: \begin{equation} \theta^i \theta^{jk} [3] = \theta^i \theta^{jk} + \theta^j \theta^{ik} + \theta^k \theta^{ij} \end{equation} This is supposed to mean as follows: sum over all possible permutations (in this case 3) of the indices. The indices of a given theta are symmetric and need not be counted twice.

Another example would be $\theta^i \theta^j \theta^{kl}$ [6]. In this case there is a total of 6 terms:







Going to even higher order, $\theta^{ij} \theta^{kl} \theta^{mn}$ [15] has 15 terms, and etc.

I am unaware of any closed expressions for the number of terms. Thus, I was trying to use Mathematica to numerically compute all terms involved in a given permutation.

However, so far I have been entirely unsuccessful. Any ideas?

Here are some (failed) attempts, made with 4 indices and the combination $\theta^i \theta^j \theta^{kl}$. This lists all permutations of four terms.

perm = Permutations[{a, b, c, d}]

I can use Mr. Wizard's dynP to partition in the size I want. For instance,


So, an alternative, would be to do this for all members of perm, and then eliminate duplicates according to the above-specified criteria. This, however, I failed to do.

I appreciate any help in advance.

Best regards,



3 Answers 3


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.

  • $\begingroup$ This works great and also agrees with Carraher's answer. Thank you very much. Do you have any references in which I could learn more from these types of calculations. I think I will soon encounter more complicated combinations. Thank you very much for the help. $\endgroup$ Commented Mar 13, 2013 at 2:23
  • 2
    $\begingroup$ Richard Stanley, Enumerative Combinatorics. $\endgroup$
    – whuber
    Commented Mar 13, 2013 at 4:45

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.



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.

  • $\begingroup$ This is precisely the type of Sort syntax that I was trying to figure out. Thanks for the help. $\endgroup$ Commented Mar 13, 2013 at 2:30
  • $\begingroup$ Glad to hear that. Sort seemed to be the key to avoiding equivalent permutations (equivalent in a special sense here). There are likely to be more elegant or efficient ways of doing it. $\endgroup$
    – DavidC
    Commented Mar 13, 2013 at 2:37
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

  • $\begingroup$ +1 There's quite a bit I can learn from your approach. $\endgroup$
    – DavidC
    Commented Mar 13, 2013 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.