def sampling_P(condition, given_condition=None, numsamples=1, evalf=True, **kwargs):
 count_true = 0
 count_false = 0
 samples = sample_iter(condition, given_condition, numsamples=numsamples, **kwargs)
 for x in samples:
  if ((x != True) and (x != False)):
   raise ValueError('Conditions must not contain free symbols')
  if x:
   count_true += 1
  else:
   count_false += 1
 result = (S(count_true) / numsamples)
 if evalf:
  return result.evalf()
 else:
  return result

def sampling_P ( condition , given_condition = None , numsamples = 1 , evalf = True , ** kwargs ) : count_true = 0 count_false = 0 samples = sample_iter ( condition , given_condition , numsamples = numsamples , ** kwargs ) for x in samples : if ( ( x != True ) and ( x != False ) ) : raise ValueError ( 'Conditions must not contain free symbols' ) if x : count_true += 1 else : count_false += 1 result = ( S ( count_true ) / numsamples ) if evalf : return result . evalf ( ) else : return result
sampling version of p see also p sampling_e sampling_density .