def sampling_E(expr, given_condition=None, numsamples=1, evalf=True, **kwargs):
 samples = sample_iter(expr, given_condition, numsamples=numsamples, **kwargs)
 result = (Add(*list(samples)) / numsamples)
 if evalf:
  return result.evalf()
 else:
  return result

def sampling_E ( expr , given_condition = None , numsamples = 1 , evalf = True , ** kwargs ) : samples = sample_iter ( expr , given_condition , numsamples = numsamples , ** kwargs ) result = ( Add ( * list ( samples ) ) / numsamples ) if evalf : return result . evalf ( ) else : return result
sampling version of e see also p sampling_p sampling_density .