\[\DeclareMathOperator{\erf}{erf} \DeclareMathOperator{\argmin}{argmin} \newcommand{\R}{\mathbb{R}} \newcommand{\n}{\boldsymbol{n}}\]

Module pyqt_fit.utils

Author:Pierre Barbier de Reuille <pierre.barbierdereuille@gmail.com>

Module contained a variety of small useful functions.

pyqt_fit.utils.namedtuple(typename, field_names, verbose=False, rename=False)[source]

Returns a new subclass of tuple with named fields.

>>> Point = namedtuple('Point', 'x y')
>>> Point.__doc__                   # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22)             # instantiate with positional args or keywords
>>> p[0] + p[1]                     # indexable like a plain tuple
33
>>> x, y = p                        # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y                       # fields also accessable by name
33
>>> d = p._asdict()                 # convert to a dictionary
>>> d['x']
11
>>> Point(**d)                      # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
pyqt_fit.utils.approx_jacobian(x, func, epsilon, *args)[source]

Approximate the Jacobian matrix of callable function func

Parameters:
  • x (ndarray) – The state vector at which the Jacobian matrix is desired
  • func (callable) – A vector-valued function of the form f(x,*args)
  • epsilon (ndarray) – The peturbation used to determine the partial derivatives
  • args (tuple) – Additional arguments passed to func
Returns:

An array of dimensions (lenf, lenx) where lenf is the length of the outputs of func, and lenx is the number of

Note

The approximation is done using forward differences

Previous topic

Module pyqt_fit.kernels

This Page