Ejemplo n.º 1
0
 def __call__(self):
     if self.model!='nugget':
         # what are 3 and 10? should these be parametrizable?
         params = fit_function(self.x, self.y, self.model, 3, 10)
     else:
         # what are 1 and 1? should these be parametrizable?
         params = fit_function(self.x, self.y, self.model, 1, 1)
     
     return self.model(self.x, params)
Ejemplo n.º 2
0
    def __call__(self):
        if self.model_text != 'nugget':
            # what are 3 and 10? should these be parametrizable?
            params = fit_function(self.x, self.y, self.model, 3, 10)
            y = self.model(self.x, params)
        else:
            # what are 1 and 1? should these be parametrizable?
            params = fit_function(self.x, self.y, self.model, 1, 1)
            y = [self.model(self.x, params)] * len(self.x)

        return y, params, self.text
Ejemplo n.º 3
0
 def __call__(self):
     if self.model_text!='nugget':
         # what are 3 and 10? should these be parametrizable?
         params = fit_function(self.x, self.y, self.model, 3, 10)
         y = self.model(self.x, params)
     else:
         # what are 1 and 1? should these be parametrizable?
         params = fit_function(self.x, self.y, self.model, 1, 1)
         y = [self.model(self.x, params)] * len(self.x)
         
     return y, params, self.text
Ejemplo n.º 4
0
 def test_exponential(self):
     """test exponential approximation"""
     # defining our fitting function
     def f(x,a):
         return exp(a[0]+x*a[1])
     
     exp_params = [2, 10]
     x = arange(-1,1,.01)
     y = f(x, exp_params)
     y_noise = y + rand(len(y))
     
     params = fit_function(x, y_noise, f, 2, 5)
     
     self.assertFloatEqual(params, exp_params , .5)
Ejemplo n.º 5
0
 def test_constant(self):
     """test constant approximation"""
     # defining our fitting function
     def f(x,a):
         return a[0]
     
     exp_params = [2]
     x = arange(-1,1,.01)
     y = f(x, exp_params)
     y_noise = y + rand(len(x))
     
     params = fit_function(x, y_noise, f, 1, 5)
     
     self.assertFloatEqual(params, exp_params , .5)
Ejemplo n.º 6
0
 def test_exponential(self):
     """test exponential approximation"""
     # defining our fitting function
     def f(x,a):
         return exp(a[0]+x*a[1])
     
     exp_params = [2, 10]
     x = arange(-1,1,.01)
     y = f(x, exp_params)
     y_noise = y + rand(len(y))
     
     params = fit_function(x, y_noise, f, 2, 5)
     
     self.assertFloatEqual(params, exp_params , .5)
Ejemplo n.º 7
0
 def test_constant(self):
     """test constant approximation"""
     # defining our fitting function
     def f(x,a):
         return a[0]
     
     exp_params = [2]
     x = arange(-1,1,.01)
     y = f(x, exp_params)
     y_noise = y + rand(len(x))
     
     params = fit_function(x, y_noise, f, 1, 5)
     
     self.assertFloatEqual(params, exp_params , .5)