class_docstr: Class for Compound Distributions.
  
  Parameters
  ==========
  
  dist : Distribution
      Distribution must contain a random parameter
  
  Examples
  ========
  
  >>> from sympy.stats.compound_rv import CompoundDistribution
  >>> from sympy.stats.crv_types import NormalDistribution
  >>> from sympy.stats import Normal
  >>> from sympy.abc import x
  >>> X = Normal('X', 2, 4)
  >>> N = NormalDistribution(X, 4)
  >>> C = CompoundDistribution(N)
  >>> C.set
  Interval(-oo, oo)
  >>> C.pdf(x, evaluate=True).simplify()
  exp(-x**2/64 + x/16 - 1/16)/(8*sqrt(pi))
  
  References
  ==========
  
  .. [1] https://en.wikipedia.org/wiki/Compound_probability_distribution
code: def _marginalise(self, expr, rv, evaluate):
      if isinstance(rv.pspace.distribution, SingleFiniteDistribution):
          rv_dens = rv.pspace.distribution.pmf(rv)
      else:
          rv_dens = rv.pspace.distribution.pdf(rv)
      rv_dom = rv.pspace.domain.set
      if rv.pspace.is_Discrete or rv.pspace.is_Finite:
          expr = Sum(expr * rv_dens, (rv, rv_dom._inf, rv_dom._sup))
      else:
          expr = Integral(
              expr * rv_dens, (rv, rv_dom._inf, rv_dom._sup)
          )
      if evaluate:
          return expr.doit()
      return expr
  
imports: from sympy.concrete.summations import Sum
  from sympy.core.basic import Basic
  from sympy.core.function import Lambda
  from sympy.core.symbol import Dummy
  from sympy.integrals.integrals import Integral
  from sympy.stats.rv import NamedArgsMixin, random_symbols, _symbol_converter, PSpace, RandomSymbol, is_random, Distribution
  from sympy.stats.crv import ContinuousDistribution, SingleContinuousPSpace
  from sympy.stats.drv import DiscreteDistribution, SingleDiscretePSpace
  from sympy.stats.frv import SingleFiniteDistribution, SingleFinitePSpace
  from sympy.stats.crv_types import ContinuousDistributionHandmade
  from sympy.stats.drv_types import DiscreteDistributionHandmade
  from sympy.stats.frv_types import FiniteDistributionHandmade
label_desc: Use image node_id 7 for calling the CompoundDistribution obj's underlying member method code with example usage: obj._marginalise(expr, rv, evaluate) and returns: expr, expr