예제 #1
0
def discrete_finite_neg_log_mass(pmf, var_names_and_values={}):
    v = var_names_and_values.copy()
    for var, value in list(var_names_and_values.items()):
        if (value is None) or is_non_atomic_sympy_expr(value):
            del v[var]
    s0 = set(v.items())
    d = MathDict(())
    for var_names_and_values___frozen_dict, func_value in list(pmf.Param['NegLogP'].items()):
        spare_var_values = dict(s0 - set(var_names_and_values___frozen_dict.items()))
        s = set(spare_var_values.keys())
        if not(s) or (s and not(s & set(var_names_and_values___frozen_dict))):
            d[var_names_and_values___frozen_dict] = sympy_xreplace(func_value, var_names_and_values)
    return d
예제 #2
0
def discrete_finite_neg_log_mass(pmf, var_names_and_values={}):
    v = var_names_and_values.copy()
    for var, value in var_names_and_values.items():
        if (value is None) or is_non_atomic_sympy_expr(value):
            del v[var]
    s0 = set(v.items())
    d = MathDict(())
    for var_names_and_values___frozen_dict, func_value in pmf.Param['NegLogP'].items():
        spare_var_values = dict(s0 - set(var_names_and_values___frozen_dict.items()))
        s = set(spare_var_values.keys())
        if not(s) or (s and not(s & set(var_names_and_values___frozen_dict))):
            d[var_names_and_values___frozen_dict] = sympy_xreplace(func_value, var_names_and_values)
    return d
예제 #3
0
 def __init__(self, var_names_and_syms={}, dict_or_expr={}):
     if hasattr(dict_or_expr, 'keys'):
         for k, v in dict_or_expr.items():
             dict_or_expr[k] = CompyledFunc(var_names_and_syms=var_names_and_syms, dict_or_expr=v)
         self.Compyled = dict_or_expr
     elif is_non_atomic_sympy_expr(dict_or_expr):
         self.Vars = tuple(var for var, symbol in var_names_and_syms.items()
                           if symbol and not(isinstance(symbol, FLOAT_TYPES)))
         inputs = (var_names_and_syms[var] for var in self.Vars)
         if use_theano:
             self.Compyled = theano_function(inputs, (dict_or_expr,), allow_input_downcast=True)
         else:
             self.Compyled = ufuncify(inputs, dict_or_expr)
     else:
         self.Compyled = sympy_to_float(dict_or_expr)
예제 #4
0
 def __init__(self, var_names_and_syms={}, dict_or_expr={}):
     if hasattr(dict_or_expr, 'keys'):
         for k, v in list(dict_or_expr.items()):
             dict_or_expr[k] = CompyledFunc(
                 var_names_and_syms=var_names_and_syms, dict_or_expr=v)
         self.Compyled = dict_or_expr
     elif is_non_atomic_sympy_expr(dict_or_expr):
         self.Vars = tuple(
             var for var, symbol in list(var_names_and_syms.items())
             if symbol and not (isinstance(symbol, FLOAT_TYPES)))
         inputs = (var_names_and_syms[var] for var in self.Vars)
         if use_theano:
             self.Compyled = theano_function(inputs, (dict_or_expr, ),
                                             allow_input_downcast=True)
         else:
             self.Compyled = ufuncify(inputs, dict_or_expr)
     else:
         self.Compyled = sympy_to_float(dict_or_expr)