def rv_subs(expr, symbols=None):
 if (symbols is None):
  symbols = random_symbols(expr)
 if (not symbols):
  return expr
 swapdict = {rv: rv.symbol for rv in symbols}
 return expr.xreplace(swapdict)

def rv_subs ( expr , symbols = None ) : if ( symbols is None ) : symbols = random_symbols ( expr ) if ( not symbols ) : return expr swapdict = { rv : rv . symbol for rv in symbols } return expr . xreplace ( swapdict )
given a random expression replace all random variables with their symbols .