Class Model
source code
Class to create a model using different Functions 
  each with their associated parameters. This Model can then be used to fit
  data using the Minimizer class.  The Model can be evaluated using the 
  evaluate method. Parameters can be added/updated, 
  together with boundaries and expressions, and can be hold fixed or 
  adjusted by changing the vary keyword in update_parameter.
  Parameters for the different Functions are combined. To keep track of 
  which parameter is which, they get a number added to the end indicating 
  the function they belong to. For example: when a Model is created summing
  a gaussian function with a quadratic function. The gaussian has 
  parameters [a, mu, sigma, c] and the quadratic function has parameters 
  [s0, s1, s2]. If the functions are provided in order [Gaussian, 
  Quadratic], the parameters will be renames to: [a_0, mu_0, sigma_0, c_0] 
  and [s0_1, s1_1, s2_1]. Keep in mind that this renaming only happens in 
  the Model object. In the underlying Functions the parameters will keep 
  there original name.
  The functions themselfs can be combined using a mathematical 
  expression in the constructor. If no expression is provided, the output 
  of each function is summed up. Keep in mind that each function needs to 
  have the same output shape:
   Model(x) = Function1(x) + Function2(x) + ...
  The provided expression needs to be a function taking an array with 
  the results of the Functions in the model as arguments, and having an 
  numpy array as result. This can be done with simple lambda 
  expression or more complicated functions:
   Model(x) = Expr( [Function1(x),Function2(x),...] ) 
  The internal representation of the parameters uses a parameter object 
  of the lmfit package. No knowledge of this repersentation is 
  required as methods for direct interaction with the parameter values and 
  other settings are provided. If wanted, the parameters object itself can 
  be obtained with the parameters attribute.
  At the moment the use of a jacobian is not supported at the Model 
  level as it is not possible to derive a symbolic jacobian from the 
  provided functions. If you want to use a jacobian you will have to write 
  a Function yourself in which you can provide a jacobian function.
    |  | 
        
          | __init__(self,
        functions=None,
        expr=None,
        resfunc=None) Create a new Model by providing the functions of which it consists.
 | source code |  | 
  
    | Inherited from object:__delattr__,__format__,__getattribute__,__hash__,__new__,__reduce__,__reduce_ex__,__repr__,__setattr__,__sizeof__,__subclasshook__ | 
  
    | numpy array | 
        
          | evaluate(self,
        x,
        *args,
        **kwargs) Evaluate the model for the given values and optional a given 
      parameter object.
 | source code |  | 
    |  | 
        
          | evaluate_jacobian(self,
        x,
        *args) Not implemented!
 | source code |  | 
    |  |  | 
    |  |  | 
    | numpy arrays | 
        
          | get_parameters(self,
        parameters=None,
        error='stderr',
        full_output=False) Returns the parameter values together with the errors if they exist.
 | source code |  | 
  
    | string | 
        
          | param2str(self,
        **kwargs) Converts the parameter object of this model to an easy printable 
      string, including the value, error, boundaries, if the parameter is 
      varied, and if in the fitting process on of the boundaries was 
      reached.
 | source code |  | 
    | string | 
        
          | correl2str(self,
        **kwargs) Convert the correlations between the different parameters of this 
      model to an easy printable string.
 | source code |  | 
    | string | 
        
          | ci2str(self,
        **kwargs) Convert the confidence intervals of the parameters of this model to 
      an easy printable string.
 | source code |  | 
  
    |  |  | 
  
    |  | 
        
          | pull_parameters(self) Pulls the parameter objects from the underlying functions, and 
      combines it to 1 parameter object.
 | source code |  | 
    |  | 
        
          | push_parameters(self,
        parameters=None) Pushes the parameters in the combined parameter object to the 
      parameter objects of the underlying models or functions.
 | source code |  | 
    |  |  | 
  
    | Inherited from object:__class__ | 
| 
  | __init__(self,
        functions=None,
        expr=None,
        resfunc=None)
    (Constructor)
 | source code |  Create a new Model by providing the functions of which it consists. 
  You can provid an expression describing how the Functions have to be 
  combined as well. This expression needs to take the out put of the 
  Fuctions in an array as argument, and provide a new numpy array as 
  result. 
    Parameters:
        functions(list) - A list of Functionsexpr(function) - An expression to combine the given functions.resfunc(function) - A function to calculate the residuals (Not obligatory)Overrides:
        object.__init__
     | 
 
| Evaluate the model for the given values and optional a given parameter
  object. If no parameter object is given then the parameter object 
  belonging to the model is used. 
>>> evaluate(x, parameters)
>>> evaluate(x) 
    Parameters:
        x(array) - the independant values for which to evaluate the model.Returns: numpy arrayModel(x) | 
 
| 
  | setup_parameters(self,
        values=None,
        bounds=None,
        vary=None,
        exprs=None)
   | source code |  Not implemented yet, use the setup_parameters method of the Functions themselfs, or 
  for adjustments of a single parameter use the update_parameter function Please provide feedback on redmine on how you would like to use this 
  function!!! 
   | 
 
| 
  | update_parameter(self,
        parameter=None,
        **kwargs)
   | source code |  Updates a specified parameter. The parameter can be given by name or 
  by index. However, you have to be carefull when using the names. The 
  model class changes the names of the parameters of the underlying 
  functions based on the order in which the functions are provided (See 
  introduction). This method also supports the use of kwargs min and max to
  set the lower and upper boundary separatly. Example use: 
>>> update_parameter(parameter='parname_0', value=10.0, min=5.0, vary=True)
>>> update_parameter(parameter=2, value=0.15, bounds=(0.10, 0.20)) 
   | 
 
| 
  | get_parameters(self,
        parameters=None,
        error='stderr',
        full_output=False)
   | source code |  Returns the parameter values together with the errors if they exist. 
  If No fitting has been done, or the errors could not be calculated, None 
  is returned for the error. The parameters of which the settings should be returned can be given 
  in parameters. If None is given, all parameters are returned. 
    Parameters:
        parameters(array) - Parameters to be returned or None for all parameters.error(string) - Which error to return ('stderr', 'mcerr')full_output(bool) - When True, also vary, the boundaries and expression are returnedReturns: numpy arraysthe parameter values and there errors: value, err, [vary, min, 
          max, expr] | 
 
| Converts the parameter object of this model to an easy printable 
  string, including the value, error, boundaries, if the parameter is 
  varied, and if in the fitting process on of the boundaries was 
  reached. The error to be printed can be set with the error keyword. You can 
  chose from the standard error: 'stderr', the monte carlo error: 'mcerr', 
  or any of the confidence intervalls that you have calculated by coding 
  them like: 'ci###'. Fx: 95% (sigma = 0.95) use 'ci95', for 99.7% (sigma =
  0.997) use 'ci997'. Don't put decimal signs in the ci! The accuracy with which the parameters are printed can be set with the
  accuracy keyword. And the amount of information that is printed is 
  determined by full_output. If False, only parameter value and error are 
  printed, if True also boundaries and vary are shown. 
    Parameters:
        accuracy(int) - Number of decimal places to printerror(string) - Which error type to print ('stderr', 'mcerr' or 'ci###')full_output(bool) - Amount of information to printReturns: stringparameters in string format | 
 
| Convert the correlations between the different parameters of this 
  model to an easy printable string. The correlations are only printed if 
  they are larger than a certain provided limit. And the accuracy keyword 
  sets the amount of decimals to print 
    Parameters:
        accuracy- number of decimal places to printlimit- minimum correlation value to printReturns: stringcorrelation in string format | 
 
| Convert the confidence intervals of the parameters of this model to an
  easy printable string. The accuracy with wich the CIs should be printed can be set with the 
  accuracy keyword. 
    Parameters:
        accuracy(int) - Number of decimal places to printReturns: stringconfidence intervals in string format | 
 
| get par_names 
    Decorators: | 
 
| 
  | __str__(self)
    (Informal representation operator)
 | source code |  String representation of the Model object 
    Overrides:
        object.__str__
     |