def test_constant0_variable_2(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     const = Constant0()
     values = [0.0000001, 0.0000001, 0.0000002]
     loglikeli = const.calculate_loglikelihood(values)
     if abs(loglikeli) < 10000000:
         raise Exception("problem in managing constant variables")
     rand = RandomVariable()
     rand.calculate_parameters(values)
     if not rand.get_distribution_type() == "IMMEDIATE":
         raise Exception("Expected a constant!")
     loglikeli = rand.calculate_loglikelihood(values)
     if abs(loglikeli) < 10000000:
         raise Exception("problem in managing constant variables (2)")
 def test_normal_variable(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     mu = 53
     sigma = 4
     tol = 0.15
     norm = Normal(mu=mu, sigma=sigma)
     values = norm.get_values(no_values=400)
     rand = RandomVariable()
     rand.calculate_parameters(values)
     if not rand.get_distribution_type() == "NORMAL":
         raise Exception("Excepted a normal!")
     mu_r = rand.random_variable.mu
     sigma_r = rand.random_variable.sigma
     diff_value_mu = abs(mu - mu_r) / (max(abs(mu), abs(mu_r)))
     diff_value_sigma = abs(sigma - sigma_r) / (max(abs(sigma), abs(sigma_r)))
     if diff_value_mu > tol or diff_value_sigma > tol:
         raise Exception("parameters found outside tolerance")
 def test_exponential_variable(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     loc = 0
     scale = 5
     tol = 0.2
     exp = Exponential(loc=loc, scale=scale)
     values = exp.get_values(no_values=400)
     rand = RandomVariable()
     rand.calculate_parameters(values)
     if not rand.get_distribution_type() == "EXPONENTIAL":
         raise Exception("Expected an exponential!")
     loc_r = rand.random_variable.loc
     scale_r = rand.random_variable.scale
     diff_value_loc = abs(loc - loc_r) / (max(abs(loc), abs(loc_r)) + 0.000001)
     diff_value_scale = abs(scale - scale_r) / (max(abs(scale), abs(scale_r)) + 0.000001)
     if diff_value_loc > tol or diff_value_scale > tol:
         raise Exception("parameters found outside tolerance")
 def test_uniform_variable(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     loc = 53
     scale = 32
     tol = 0.15
     unif = Uniform(loc=loc, scale=scale)
     values = unif.get_values(no_values=400)
     rand = RandomVariable()
     rand.calculate_parameters(values)
     if not rand.get_distribution_type() == "UNIFORM":
         raise Exception("Expected an uniform!")
     loc_r = rand.random_variable.loc
     scale_r = rand.random_variable.scale
     diff_value_loc = abs(loc - loc_r) / (max(abs(loc), abs(loc_r)))
     diff_value_scale = abs(scale - scale_r) / (max(abs(scale), abs(scale_r)))
     if diff_value_loc > tol or diff_value_scale > tol:
         raise Exception("parameters found outside tolerance")