1
$\begingroup$

How do I compute the following expectation value concerning the Digamma function $\psi(k)$:

$$\langle k\, \psi(k)\rangle=\sum_{k=0}^n {n\choose{k}}\,p^k(1-p)^{n-k}\, k \,\psi(k)$$

I have tried:

Sum[Binomial[n, k] p^k (1 - p)^(n - k) k PolyGamma[k], {k, 0, n}] 

but that gives

$$-(1-p)^n$$

which can not be true.

EDIT:

The closed form solution for $n\geq 1$ is

$$\langle k\, \psi(k)\rangle=p\, n\left(\log p+\psi(n)+B_{1-p}(n,0)\right)-(1-p)^n$$

In Mathematica code:

f[p_,n_] = p n (Log[p] + PolyGamma[n] + Beta[1-p,n,0]) - (1-p)^n
$\endgroup$
  • 1
    $\begingroup$ I wonder if you can't get there from here: PolyGamma[0] = ComplexInfinity. Changing Sum to Table and putting in a specific value for n might shed some light on the issue. $\endgroup$ – JimB Jun 26 '18 at 22:47
  • 1
    $\begingroup$ Might one avoid the PolyGamma[0] problem by summing over k=1 to n, since the k=0 term does not add to the summation? $\endgroup$ – David G. Stork Jun 26 '18 at 22:51
  • 1
    $\begingroup$ @DavidG.Stork That would avoid the Polygamma[0] problem but then a truncated binomial distribution would need to be used. Otherwise it would not be the expectation if the sum of the probabilities don't add up to 1. $\endgroup$ – JimB Jun 26 '18 at 23:07
4
$\begingroup$

For n == 0evaluate the limit

Limit[Binomial[0, k] p^k (1 - p)^-k k PolyGamma[k], k -> 0]

(* -1 *)

Include assumptions

ex[n_, p_] = 
 Assuming[{0 <= p <= 1, Element[n, Integers], n > 0}, 
  Sum[Binomial[n, k] p^k (1 - p)^(n - k) k PolyGamma[k], {k, 0, n}] // 
   Simplify]

enter image description here

Although the assumptions excluded n == 0, evaluating this expression for n == 0 is consistent with the limit above

ex[0, p]

(* -1 *)

{#, ex[#, p]} & /@ Range[0, 10] //
   Simplify //
  Prepend[#, 
    Style[#, 14, Bold] & /@ {"n", 
      "〈k ψ(k)〉"}] & //
 Grid[#, Frame -> All] &

enter image description here

Plot[Evaluate@Table[Tooltip[ex[n, p], n], {n, 10, 0, -2}], {p, 0, 1}, 
 PlotLegends -> Placed[Range[10, 0, -2], {0.25, 0.65}],
 AxesLabel -> (Style[#, 14, Bold] & /@ {"p", 
     "〈k ψ(k)〉"})]

enter image description here

Note that if the assumptions include n >= 0 then the result is the same as that without assumptions.

Assuming[{0 <= p <= 1, Element[n, Integers], n >= 0}, 
 Sum[Binomial[n, k] p^k (1 - p)^(n - k) k PolyGamma[k], {k, 0, n}] // 
  Simplify]

(* -(1 - p)^n *)
$\endgroup$
  • $\begingroup$ But your figure shows that the expectation is not $-(1-p)^n$ (except for $n=0$). What am I missing? $\endgroup$ – JimB Jun 27 '18 at 3:40
  • $\begingroup$ @JimB - The last observation reflects how Mathematica might arrive at its result. I understand that the results are different under the different assumptions. $\endgroup$ – Bob Hanlon Jun 27 '18 at 3:57
  • $\begingroup$ OK. Got it now. It does seem that using Limit[k PolyGamma[k], k->0] = -1 for k PolyGamma[k] when k=0 for all values of n gives what you show in the table and figure. $\endgroup$ – JimB Jun 27 '18 at 4:03
1
$\begingroup$

The problem is that PolyGamma[k] has a simple pole in zero, i.e. PolyGamma[k] ~ -1/k +O(1). Therefore k*PolyGamma[k] is regular in zero and has value -1.

For your purpose you could define a function regular in zero, say

jj[x_] := Piecewise[{{-1, x <= 0}, {x*PolyGamma[x], x > 0}}]

So that the expectation value of jj i.e.

Sum[Binomial[n, k] p^k (1 - p)^(n - k) jj[k], {k, 0, n}]

is OK for n=0. This method reproduces the above table.

For generic n there is no simple expression. One could however easily infer that

Sum[n] ~ -1 -n*(EulerGamma-1)*p + O(p^2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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