Bases: pymodelfit.core.FunctionModel
This model contains a group of FunctionModel objects joined by standard arithmetic operations, and evaluates them as a single model. The models themselves are called, rather than the f() function (and hence will be influenced by anything like FunctionModel1D.setCall() calls).
Generated parameter names are of the form ‘A0’ and ‘A1’ where A is the parameter name and the number is the sequential number of the model with that parameter. If autoshorten is True, the suffix will be removed if there is only one of that parameter.
Note that no checking is performed here to ensure the model outputs are compatible  this can be done in subclasses for specific types of FunctionModels.
Parameters: 


Any additional arguments should be “parname=parval” form, setting the initial values for the parameters.
Parameters: 


Any additional arguments should be “parname=parval” form, setting the initial values for the parameters.
Methods
__init__([models, operation, parnames, ...]) 


chi2Data([x, y, weights, ddof])  Computes the chisquared statistic for the data assuming this model.  
f(x, *args)  The composite model function.  
fitData([x, y, fixedpars, weights, ...])  Fit the provided data using algorithms from scipy.optimize, and adjust the model parameters to match.  
fitDataFixed(*args, **kwargs)  Fits data using FunctionModel.fitData(), but allows this  
getCov()  Computes the covariance matrix for the last fitData() call.  
getMCMC(x, y[, priors, datamodel])  Generate an Markov Chain Monte Carlo sampler for the data and model.  
inv(output, *args, **kwargs)  Compute the inverse of this model for the requested output.  
isVarnumModel()  Determines if the model represented by this class accepts a variable number of parameters (i.e.  
resampleFit([x, y, xerr, yerr, bootstrap, ...])  Estimates errors via resampling.  
residuals([x, y, retdata])  Compute residuals of the provided data against the model.  
stdData([x, y])  Determines the standard deviation of the model from data. 
Attributes
data  The fitting data for this model. 
defaultparval  int(x=0) > int or long 
errors  Error on the data. 
fittype  str(object=’‘) > string 
fittypes  A Sequence of the available valid values for the fittype 
fixedpars  tuple() > empty tuple 
models  
ops  
params  A tuple of the parameter names. 
pardict  A dictionary mapping parameter names to the associated values. 
parvals  The values of the parameters in the same order as params 
rangehint  
weightstype  Determines the statistical interpretation of the weights in data. 
Computes the chisquared statistic for the data assuming this model.
Parameters: 


Returns:  tuple of floats (chi2,reducedchi2,pvalue) 
The fitting data for this model. Should be either None, or a tuple(datain,dataout,weights). Note that the weights are interpreted statistically as errors based on the weightstype attribute.
Error on the data. Sets the weights on data assuming the interpretation for errors given by weightstype. If data is None/missing, a TypeError will be raised.
Fit the provided data using algorithms from scipy.optimize, and adjust the model parameters to match.
The fitting technique is sepcified by the fittype attribute of the object, which by default can be any of the optimization types in the scipy.optimize module (except for scalar minimizers)
The full fitting output is available in lastfit attribute after this method completes.
Parameters: 


kwargs are passed into the fitting function.
Returns:  array of the best fit parameters 

Raises ModelTypeError:  
If the output of the model does not match the shape of y. 
See also
Fits data using FunctionModel.fitData(), but allows this CompositeModel to hold all parameters of one of the submodels fixed instead of fixing a list of parameters.
The provided arguments will be passed into FunctionModel.fitData(), except for fixedpars. Instead the fixedmods or freemods kwargs are used to determine which parameters should be fixed. Either can be specified, but not both.
Parameters: 


Returns:  same return value as FunctionModel.fitData() 
A Sequence of the available valid values for the fittype attribute. (Readonly)
Computes the covariance matrix for the last fitData() call.
Returns:  The covariance matrix with variables in the same order as params. Diagonal entries give the variance in each parameter. 

Warning
This is not guaranteed to work for custom fittypes, but will always work with the default (leastsq) fit.
Generate an Markov Chain Monte Carlo sampler for the data and model. This function requires the PyMC package for the MCMC internals and sampling.
Parameters: 


Raises ValueError:  
If a prior is not provided for any parameter. 

Returns:  A pymc.MCMC object ready to sample for this model. 
Compute the inverse of this model for the requested output.
Parameters:  output – The output value of the model at which to compute the inverse. 

Returns:  The input value at which the model produces output 
Raises ModelTypeError:  
If the model is not invertable for the provided data set. 
Determines if the model represented by this class accepts a variable number of parameters (i.e. number of parameters is set when the object is created).
Returns:  True if this model has a variable number of parameters. 

A tuple of the parameter names. (readonly)
A dictionary mapping parameter names to the associated values.
Estimates errors via resampling. Uses the fitData function to fit the function many times while either using the “bootstrap” technique (resampling w/replacement), monte carlo estimates for the error, or both to estimate the error in the fit.
Parameters: 


kwargs are passed into fitData
Returns:  (histd,cov) where histd is a dictionary mapping parameters to their histograms and cov is the covariance matrix of the parameters in parameter order. 

Note
If x, y, xerr, or yerr are provided, they do not overwrite the stored data, unlike most other methods for this class.
Compute residuals of the provided data against the model. E.g. .
Parameters:  

Returns:  Residuals of model from y or if retdata is True, a tuple (x,y,residuals). 
Return type:  arraylike 
Determines the standard deviation of the model from data. Data can either be provided or (by default) will be taken from the stored data.
Parameters:  

Returns:  standard deviation of model from y 
Determines the statistical interpretation of the weights in data. Can be:
Weights act as inverse errors (default)
Weights act as inverse variance
Weights act as errors (nonstandard  this makes points with larger error bars count more towards the fit).
Weights act as variance (nonstandard  this makes points with larger error bars count more towards the fit).