I have a discrete probability distribution where $P(X=x)=(Factorial[n]/(n^x))*StirlingS2[x-1,n-1]$. So, when trying to calculate its mean with the following property: $\mu = \sum_{i} x_i \cdot P(x_i)$, I insert this expression in Mathematica:

Sum[(Factorial[n]/(n^x))*StirlingS2[x - 1, n - 1]*x, {x, 0, Infinity}]

But the program doesn't output the correct answer, which in this case would be n*HarmonicNumber[n], instead it provides: $\sum _{x=0}^{\infty } x n! n^{-x} \mathcal{S}_{x-1}^{(n-1)}$ as output.

I have tried to encapsulate the operation inside FunctionExpand and FullSimplify but I can´t make it work.


1 Answer 1



$$\mathcal{S}_{x-1}^{(n-1)}=\frac{\sum _{j=0}^{n-1} (-1)^{j+n-1} \binom{n-1}{j} j^{x-1}}{(n-1)!}$$

we have:

FullSimplify[Sum[Sum[(Factorial[n]/(n^x))*((1/(n - 1)!) *(-1)^(j + n - 1)  Binomial[n - 1, j]  j^(x - 1))*x // FullSimplify, {x, 0, Infinity}] // FunctionExpand, {j, 0, n - 1}], Assumptions -> {n \[Element] PositiveIntegers}]

(*n HarmonicNumber[n]*)

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.