polar_lift 'name' problem when integrating a multidimensional gaussian

9 views
Skip to first unread message

Lorenzo Monacelli

unread,
May 2, 2020, 12:20:38 PM5/2/20
to sympy
Dear All,
I'm trying to integrate a multidimensional Gaussian with sympy. However, when I perform the integration, it crashes with an error related to polar_lift:

import sympy as sy
from sympy.abc import *

sy.init_printing()
C= sy.MatrixSymbol("C", 3, 3)
r = sy.IndexedBase("r", real = True)
a,b,c = sy.symbols("a,b,c", integer = True)

integ = sy.Integral( sy.exp(-r[a] * C[a,a] * r[a] - 2*r[a] * C[a,b] * r[b] - r[b]*C[b,b] * r[b]),
            (r[a], -sy.oo, sy.oo), (r[b], -sy.oo, sy.oo))

integ.doit()

In the last line, the code crashes with the following error


~/anaconda2/lib/python3.7/site-packages/sympy-1.6.dev0-py3.7.egg/sympy/matrices/expressions/matexpr.py
in name(self) 797 @property 798 def name(self): --> 799 return self.args[0].name 800 801 def _eval_subs(self, old, new): AttributeError: 'polar_lift' object has no attribute 'name'

If I replace the indexed variables with normal variables, the integration is performed (even if it is superslow, and if I ask for conds="none" it assumes it to diverge)

There is a way to perform integrals of multidimensional Gaussians? In principle, these kinds of integrals should be tabulated
Thanks for your attention,
Bests,
Lorenzo
Reply all
Reply to author
Forward
0 new messages