(expr, condition=None, numsamples=S.Infinity, **kwargs)
See sample_iter

    Uses subs for computation. This is slow but almost always works.
See sample_iter
See sample_iter
def sample_iter_subs(expr, condition=None, numsamples=S.Infinity, **kwargs):
    """
    See sample_iter

    Uses subs for computation. This is slow but almost always works.
    """
    if condition is not None:
        ps = pspace(Tuple(expr, condition))
    else:
        ps = pspace(expr)

    count = 0
    while count < numsamples:
        d = ps.sample()  # a dictionary that maps RVs to values

        if condition is not None:  # Check that these values satisfy the condition
            gd = condition.xreplace(d)
            if gd != True and gd != False:
                raise ValueError("Conditions must not contain free symbols")
            if not gd:  # If the values don't satisfy then try again
                continue

        yield expr.xreplace(d)
        count += 1
def sample_iter_subs ( expr , condition = None , numsamples = S . Infinity , * * kwargs ) : if condition is not None : ps = pspace ( Tuple ( expr , condition ) ) else : ps = pspace ( expr ) count = 0 while count < numsamples : d = ps . sample ( ) # a dictionary that maps RVs to values if condition is not None : # Check that these values satisfy the condition gd = condition . xreplace ( d ) if gd != True and gd != False : raise ValueError ( "Conditions must not contain free symbols" ) if not gd : # If the values don't satisfy then try again continue yield expr . xreplace ( d ) count += 1