class_docstr: Expectation of a random matrix expression.
  
  Examples
  ========
  
  >>> from sympy.stats import ExpectationMatrix, Normal
  >>> from sympy.stats.rv import RandomMatrixSymbol
  >>> from sympy import symbols, MatrixSymbol, Matrix
  >>> k = symbols("k")
  >>> A, B = MatrixSymbol("A", k, k), MatrixSymbol("B", k, k)
  >>> X, Y = RandomMatrixSymbol("X", k, 1), RandomMatrixSymbol("Y", k, 1)
  >>> ExpectationMatrix(X)
  ExpectationMatrix(X)
  >>> ExpectationMatrix(A*X).shape
  (k, 1)
  
  To expand the expectation in its expression, use ``expand()``:
  
  >>> ExpectationMatrix(A*X + B*Y).expand()
  A*ExpectationMatrix(X) + B*ExpectationMatrix(Y)
  >>> ExpectationMatrix((X + Y)*(X - Y).T).expand()
  ExpectationMatrix(X*X.T) - ExpectationMatrix(X*Y.T) + ExpectationMatrix(Y*X.T) - ExpectationMatrix(Y*Y.T)
  
  To evaluate the ``ExpectationMatrix``, use ``doit()``:
  
  >>> N11, N12 = Normal('N11', 11, 1), Normal('N12', 12, 1)
  >>> N21, N22 = Normal('N21', 21, 1), Normal('N22', 22, 1)
  >>> M11, M12 = Normal('M11', 1, 1), Normal('M12', 2, 1)
  >>> M21, M22 = Normal('M21', 3, 1), Normal('M22', 4, 1)
  >>> x1 = Matrix([[N11, N12], [N21, N22]])
  >>> x2 = Matrix([[M11, M12], [M21, M22]])
  >>> ExpectationMatrix(x1 + x2).doit()
  Matrix([
  [12, 14],
  [24, 26]])
class_docstr_tok: ["Expectation","of","a","random","matrix","expression",".","Examples","========",">",">",">","from","sympy.stats","import","ExpectationMatrix",",","Normal",">",">",">","from","sympy.stats.rv","import","RandomMatrixSymbol",">",">",">","from","sympy","import","symbols",",","MatrixSymbol",",","Matrix",">",">",">","k","=","symbols","(","``","k","''",")",">",">",">","A",",","B","=","MatrixSymbol","(","``","A","''",",","k",",","k",")",",","MatrixSymbol","(","``","B","''",",","k",",","k",")",">",">",">","X",",","Y","=","RandomMatrixSymbol","(","``","X","''",",","k",",","1",")",",","RandomMatrixSymbol","(","``","Y","''",",","k",",","1",")",">",">",">","ExpectationMatrix","(","X",")","ExpectationMatrix","(","X",")",">",">",">","ExpectationMatrix","(","A","*","X",")",".shape","(","k",",","1",")","To","expand","the","expectation","in","its","expression",",","use","``","expand","(",")","``",":",">",">",">","ExpectationMatrix","(","A","*","X","+","B","*","Y",")",".expand","(",")","A","*","ExpectationMatrix","(","X",")","+","B","*","ExpectationMatrix","(","Y",")",">",">",">","ExpectationMatrix","(","(","X","+","Y",")","*","(","X","-","Y",")",".T",")",".expand","(",")","ExpectationMatrix","(","X","*","X.T",")","-","ExpectationMatrix","(","X","*","Y.T",")","+","ExpectationMatrix","(","Y","*","X.T",")","-","ExpectationMatrix","(","Y","*","Y.T",")","To","evaluate","the","``","ExpectationMatrix","``",",","use","``","doit","(",")","``",":",">",">",">","N11",",","N12","=","Normal","(","'N11","'",",","11",",","1",")",",","Normal","(","'N12","'",",","12",",","1",")",">",">",">","N21",",","N22","=","Normal","(","'N21","'",",","21",",","1",")",",","Normal","(","'N22","'",",","22",",","1",")",">",">",">","M11",",","M12","=","Normal","(","'M11","'",",","1",",","1",")",",","Normal","(","'M12","'",",","2",",","1",")",">",">",">","M21",",","M22","=","Normal","(","'M21","'",",","3",",","1",")",",","Normal","(","'M22","'",",","4",",","1",")",">",">",">","x1","=","Matrix","(","[","[","N11",",","N12","]",",","[","N21",",","N22","]","]",")",">",">",">","x2","=","Matrix","(","[","[","M11",",","M12","]",",","[","M21",",","M22","]","]",")",">",">",">","ExpectationMatrix","(","x1","+","x2",")",".doit","(",")","Matrix","(","[","[","12",",","14","]",",","[","24",",","26","]","]",")"]
code: def shape(self):
      return self._shape
  
imports: import itertools
  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.singleton import S
  from sympy.matrices.exceptions import ShapeError
  from sympy.matrices.expressions.matexpr import MatrixExpr
  from sympy.matrices.expressions.matmul import MatMul
  from sympy.matrices.expressions.special import ZeroMatrix
  from sympy.stats.rv import RandomSymbol, is_random
  from sympy.core.sympify import _sympify
  from sympy.stats.symbolic_probability import Variance, Covariance, Expectation
label_desc: Use image node_id 2 for calling the ExpectationMatrix obj's underlying member method code with example usage: obj.shape() and returns: self