def pspace(expr):
 expr = sympify(expr)
 rvs = random_symbols(expr)
 if (not rvs):
  raise ValueError(('Expression containing Random Variable expected, not %s' % expr))
 if all(((rv.pspace == rvs[0].pspace) for rv in rvs)):
  return rvs[0].pspace
 return ProductPSpace(*[rv.pspace for rv in rvs])

def pspace ( expr ) : expr = sympify ( expr ) rvs = random_symbols ( expr ) if ( not rvs ) : raise ValueError ( ( 'Expression containing Random Variable expected, not %s' % expr ) ) if all ( ( ( rv . pspace == rvs [ 0 ] . pspace ) for rv in rvs ) ) : return rvs [ 0 ] . pspace return ProductPSpace ( * [ rv . pspace for rv in rvs ] )
returns the underlying probability space of a random expression .