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

    Uses lambdify for computation. This is fast but does not always work.
See sample_iter
See sample_iter
def sample_iter_lambdify(expr, condition=None, numsamples=S.Infinity, **kwargs):
    """
    See sample_iter

    Uses lambdify for computation. This is fast but does not always work.
    """
    if condition:
        ps = pspace(Tuple(expr, condition))
    else:
        ps = pspace(expr)

    rvs = list(ps.values)
    fn = lambdify(rvs, expr, **kwargs)
    if condition:
        given_fn = lambdify(rvs, condition, **kwargs)

    # Check that lambdify can handle the expression
    # Some operations like Sum can prove difficult
    try:
        d = ps.sample()  # a dictionary that maps RVs to values
        args = [d[rv] for rv in rvs]
        fn(*args)
        if condition:
            given_fn(*args)
    except:
        raise TypeError("Expr/condition too complex for lambdify")

    def return_generator():
        count = 0
        while count < numsamples:
            d = ps.sample()  # a dictionary that maps RVs to values
            args = [d[rv] for rv in rvs]

            if condition:  # Check that these values satisfy the condition
                gd = given_fn(*args)
                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 fn(*args)
            count += 1
    return return_generator()
def sample_iter_lambdify ( expr , condition = None , numsamples = S . Infinity , * * kwargs ) : if condition : ps = pspace ( Tuple ( expr , condition ) ) else : ps = pspace ( expr ) rvs = list ( ps . values ) fn = lambdify ( rvs , expr , * * kwargs ) if condition : given_fn = lambdify ( rvs , condition , * * kwargs ) # Check that lambdify can handle the expression # Some operations like Sum can prove difficult try : d = ps . sample ( ) # a dictionary that maps RVs to values args = [ d [ rv ] for rv in rvs ] fn ( * args ) if condition : given_fn ( * args ) except : raise TypeError ( "Expr/condition too complex for lambdify" ) def return_generator ( ) : count = 0 while count < numsamples : d = ps . sample ( ) # a dictionary that maps RVs to values args = [ d [ rv ] for rv in rvs ] if condition : # Check that these values satisfy the condition gd = given_fn ( * args ) 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 fn ( * args ) count += 1 return return_generator ( )