scipy.odr.Model

class scipy.odr.Model(fcn, fjacb=None, fjacd=None, extra_args=None, estimate=None, implicit=0, meta=None)[source]

The Model class stores information about the function you wish to fit.

It stores the function itself, at the least, and optionally stores functions which compute the Jacobians used during fitting. Also, one can provide a function that will provide reasonable starting values for the fit parameters possibly given the set of data.

Parameters:

fcn : function

fcn(beta, x) –> y

fjacb : function

Jacobian of fcn wrt the fit parameters beta.

fjacb(beta, x) –> @f_i(x,B)/@B_j

fjacd : function

Jacobian of fcn wrt the (possibly multidimensional) input variable.

fjacd(beta, x) –> @f_i(x,B)/@x_j

extra_args : tuple, optional

If specified, extra_args should be a tuple of extra arguments to pass to fcn, fjacb, and fjacd. Each will be called by apply(fcn, (beta, x) + extra_args)

estimate : array_like of rank-1

Provides estimates of the fit parameters from the data

estimate(data) –> estbeta

implicit : boolean

If TRUE, specifies that the model is implicit; i.e fcn(beta, x) ~= 0 and there is no y data to fit against

meta : dict, optional

freeform dictionary of metadata for the model

Notes

Note that the fcn, fjacb, and fjacd operate on NumPy arrays and return a NumPy array. The estimate object takes an instance of the Data class.

Here are the rules for the shapes of the argument and return arrays of the callback functions:

x
if the input data is single-dimensional, then x is rank-1 array; i.e. x = array([1, 2, 3, ...]); x.shape = (n,) If the input data is multi-dimensional, then x is a rank-2 array; i.e., x = array([[1, 2, ...], [2, 4, ...]]); x.shape = (m, n). In all cases, it has the same shape as the input data array passed to odr. m is the dimensionality of the input data, n is the number of observations.
y
if the response variable is single-dimensional, then y is a rank-1 array, i.e., y = array([2, 4, ...]); y.shape = (n,). If the response variable is multi-dimensional, then y is a rank-2 array, i.e., y = array([[2, 4, ...], [3, 6, ...]]); y.shape = (q, n) where q is the dimensionality of the response variable.
beta
rank-1 array of length p where p is the number of parameters; i.e. beta = array([B_1, B_2, ..., B_p])
fjacb
if the response variable is multi-dimensional, then the return array’s shape is (q, p, n) such that fjacb(x,beta)[l,k,i] = d f_l(X,B)/d B_k evaluated at the i’th data point. If q == 1, then the return array is only rank-2 and with shape (p, n).
fjacd
as with fjacb, only the return array’s shape is (q, m, n) such that fjacd(x,beta)[l,j,i] = d f_l(X,B)/d X_j at the i’th data point. If q == 1, then the return array’s shape is (m, n). If m == 1, the shape is (q, n). If m == q == 1, the shape is (n,).

Methods

set_meta(**kwds) Update the metadata dictionary with the keywords and data provided here.