I was trying to compute the expected value of log(x) under the gamma
distribution, but sympy hangs using 100% CPU, and appears to be inside a
recursion loop:

....

  File "/home/keir/wrk/sympy/sympy/polys/densebasic.py", line 296, in
dmp_zero_p
    return dmp_zero_p(f[0], u-1)
  File "/home/keir/wrk/sympy/sympy/polys/densebasic.py", line 296, in
dmp_zero_p
    return dmp_zero_p(f[0], u-1)
  File "/home/keir/wrk/sympy/sympy/polys/densebasic.py", line 296, in
dmp_zero_p
    return dmp_zero_p(f[0], u-1)
  File "/home/keir/wrk/sympy/sympy/polys/densebasic.py", line 296, in
dmp_zero_p
    return dmp_zero_p(f[0], u-1)
  File "/home/keir/wrk/sympy/sympy/polys/densebasic.py", line 296, in
dmp_zero_p
    return dmp_zero_p(f[0], u-1)

....

Here's the code:

import sympy
from sympy import exp, log, var, integrate, oo
from sympy.functions.special.gamma_functions import gamma
x, k = var('x k')
# Compute the expected value of log(x) under a gamma distribution with theta
= 1
gamma_pdf = x**(k-1) * exp(-x) / gamma(k)
print integrate(log(x) * gamma_pdf, (x, 0, oo))

Compare with wolfram alpha:
http://integrals.wolfram.com/index.jsp?expr=log(x)x^(k-1)Exp[-x]/Gamma[k]

Any tips on how to get sympy to solve this sort of problem?

Thanks,
Keir

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to