class_docstr: Symbolic expression for the covariance.
  
  Examples
  ========
  
  >>> from sympy.stats import Covariance
  >>> from sympy.stats import Normal
  >>> X = Normal("X", 3, 2)
  >>> Y = Normal("Y", 0, 1)
  >>> Z = Normal("Z", 0, 1)
  >>> W = Normal("W", 0, 1)
  >>> cexpr = Covariance(X, Y)
  >>> cexpr
  Covariance(X, Y)
  
  Evaluate the covariance, `X` and `Y` are independent,
  therefore zero is the result:
  
  >>> cexpr.evaluate_integral()
  0
  
  Rewrite the covariance expression in terms of expectations:
  
  >>> from sympy.stats import Expectation
  >>> cexpr.rewrite(Expectation)
  Expectation(X*Y) - Expectation(X)*Expectation(Y)
  
  In order to expand the argument, use ``expand()``:
  
  >>> from sympy.abc import a, b, c, d
  >>> Covariance(a*X + b*Y, c*Z + d*W)
  Covariance(a*X + b*Y, c*Z + d*W)
  >>> Covariance(a*X + b*Y, c*Z + d*W).expand()
  a*c*Covariance(X, Z) + a*d*Covariance(W, X) + b*c*Covariance(Y, Z) + b*d*Covariance(W, Y)
  
  This class is aware of some properties of the covariance:
  
  >>> Covariance(X, X).expand()
  Variance(X)
  >>> Covariance(a*X, b*Y).expand()
  a*b*Covariance(X, Y)
class_docstr_tok: ["Symbolic","expression","for","the","covariance",".","Examples","========",">",">",">","from","sympy.stats","import","Covariance",">",">",">","from","sympy.stats","import","Normal",">",">",">","X","=","Normal","(","``","X","''",",","3",",","2",")",">",">",">","Y","=","Normal","(","``","Y","''",",","0",",","1",")",">",">",">","Z","=","Normal","(","``","Z","''",",","0",",","1",")",">",">",">","W","=","Normal","(","``","W","''",",","0",",","1",")",">",">",">","cexpr","=","Covariance","(","X",",","Y",")",">",">",">","cexpr","Covariance","(","X",",","Y",")","Evaluate","the","covariance",",","`","X","`","and","`","Y","`","are","independent",",","therefore","zero","is","the","result",":",">",">",">","cexpr.evaluate_integral","(",")","0","Rewrite","the","covariance","expression","in","terms","of","expectations",":",">",">",">","from","sympy.stats","import","Expectation",">",">",">","cexpr.rewrite","(","Expectation",")","Expectation","(","X","*","Y",")","-","Expectation","(","X",")","*","Expectation","(","Y",")","In","order","to","expand","the","argument",",","use","``","expand","(",")","``",":",">",">",">","from","sympy.abc","import","a",",","b",",","c",",","d",">",">",">","Covariance","(","a","*","X","+","b","*","Y",",","c","*","Z","+","d","*","W",")","Covariance","(","a","*","X","+","b","*","Y",",","c","*","Z","+","d","*","W",")",">",">",">","Covariance","(","a","*","X","+","b","*","Y",",","c","*","Z","+","d","*","W",")",".expand","(",")","a","*","c","*","Covariance","(","X",",","Z",")","+","a","*","d","*","Covariance","(","W",",","X",")","+","b","*","c","*","Covariance","(","Y",",","Z",")","+","b","*","d","*","Covariance","(","W",",","Y",")","This","class","is","aware","of","some","properties","of","the","covariance",":",">",">",">","Covariance","(","X",",","X",")",".expand","(",")","Variance","(","X",")",">",">",">","Covariance","(","a","*","X",",","b","*","Y",")",".expand","(",")","a","*","b","*","Covariance","(","X",",","Y",")"]
code: def expand(self, **hints):
      arg1 = self.args[0]
      arg2 = self.args[1]
      condition = self._condition
  
      if arg1 == arg2:
          return Variance(arg1, condition).expand()
  
      if not is_random(arg1):
          return S.Zero
      if not is_random(arg2):
          return S.Zero
  
      arg1, arg2 = sorted([arg1, arg2], key=default_sort_key)
  
      if isinstance(arg1, RandomSymbol) and isinstance(
          arg2, RandomSymbol
      ):
          return Covariance(arg1, arg2, condition)
  
      coeff_rv_list1 = self._expand_single_argument(arg1.expand())
      coeff_rv_list2 = self._expand_single_argument(arg2.expand())
  
      addends = [
          a
          * b
          * Covariance(
              *sorted([r1, r2], key=default_sort_key),
              condition=condition,
          )
          for (a, r1) in coeff_rv_list1
          for (b, r2) in coeff_rv_list2
      ]
      return Add.fromiter(addends)
  
imports: import itertools
  from sympy.concrete.summations import Sum
  from sympy.core.add import Add
  from sympy.core.expr import Expr
  from sympy.core.function import expand
  from sympy.core.mul import Mul
  from sympy.core.relational import Eq
  from sympy.core.singleton import S
  from sympy.core.symbol import Symbol
  from sympy.integrals.integrals import Integral
  from sympy.logic.boolalg import Not
  from sympy.core.parameters import global_parameters
  from sympy.core.sorting import default_sort_key
  from sympy.core.sympify import _sympify
  from sympy.core.relational import Relational
  from sympy.logic.boolalg import Boolean
  from sympy.stats import variance, covariance
  from sympy.stats.rv import RandomSymbol, pspace, dependent, given, sampling_E, RandomIndexedSymbol, is_random, PSpace, sampling_P, random_symbols
label_desc: Use image node_id 3 for calling the Covariance obj's underlying member method code with example usage: obj.expand() and returns: Add, Variance, S, S, Covariance