Esempio n. 1
0
 def __init__(self, thetas_prime, thetas, mu_bar, gamma_mu_bar=1., name=None):
     assert isinstance(thetas_prime, (list, tuple))
     assert isinstance(thetas, (list, tuple))
     assert len(thetas) > 0
     assert len(thetas) == len(thetas_prime)
     assert all([isinstance(theta, (Number, ParameterFunctional)) for theta in thetas])
     assert all([isinstance(theta, (Number, ParameterFunctional)) for theta in thetas_prime])
     thetas = tuple(ConstantParameterFunctional(f) if not isinstance(f, ParameterFunctional) else f
                    for f in thetas)
     thetas_prime = tuple(ConstantParameterFunctional(f) if not isinstance(f, ParameterFunctional) else f
                    for f in thetas_prime)
     if not isinstance(mu_bar, Mu):
         mu_bar = Parameters.of(thetas).parse(mu_bar)
     assert Parameters.of(thetas).assert_compatible(mu_bar)
     thetas_mu_bar = np.array([theta(mu_bar) for theta in thetas])
     assert not np.any(float_cmp(thetas_mu_bar, 0))
     assert isinstance(gamma_mu_bar, Number)
     assert gamma_mu_bar > 0
     self.__auto_init(locals())
     self.thetas_mu_bar = thetas_mu_bar
     self.theta_mu_bar_has_negative = True if np.any(thetas_mu_bar < 0) else False
     if self.theta_mu_bar_has_negative:
         # If 0 is in theta_prime(mu), we need to use the absolute value to ensure
         # that the bound is still valid (and not zero)
         self.abs_thetas_mu_bar = np.array([np.abs(theta(mu_bar)) for theta in thetas])
Esempio n. 2
0
 def __init__(self, thetas, mu_bar, alpha_mu_bar=1., name=None):
     assert isinstance(thetas, (list, tuple))
     assert len(thetas) > 0
     assert all([isinstance(theta, (Number, ParameterFunctional)) for theta in thetas])
     thetas = tuple(ConstantParameterFunctional(theta) if not isinstance(theta, ParameterFunctional) else theta
                    for theta in thetas)
     if not isinstance(mu_bar, Mu):
         mu_bar = Parameters.of(thetas).parse(mu_bar)
     assert Parameters.of(thetas).assert_compatible(mu_bar)
     thetas_mu_bar = np.array([theta(mu_bar) for theta in thetas])
     assert np.all(thetas_mu_bar > 0)
     assert isinstance(alpha_mu_bar, Number)
     assert alpha_mu_bar > 0
     self.__auto_init(locals())
     self.thetas_mu_bar = thetas_mu_bar
Esempio n. 3
0
def test_parse_parameter():
    parameters = Parameters(b=2, a=1)
    mu_as_list = [1,2,3]
    mu_as_parameter_and_back = list(parameters.parse(mu_as_list).to_numpy())
    assert mu_as_list == mu_as_parameter_and_back
Esempio n. 4
0
def space():
    return Parameters({'diffusionl': 1}).space(0.1, 1)