inversion_ideas.LinearRegressor#

class inversion_ideas.LinearRegressor(matrix, *, build_jacobian=True, cache=True)#

Linear regressor simulation.

Implements a linear regressor that generates data values as the product between its matrix and a given model vector.

Important

This class is included mainly as an example of a simple simulation class that could be created and used within the inversion framework.

Parameters:
matrix(n_data, n_params) array

Matrix used in the definition of the linear regressor.

build_jacobianbool, optional

Whether the Jacobian matrix will be created as a dense matrix (True) or as a LinearOperator (False). Default to True.

cachebool, optional

Whether to cache the results of the __call__() method for the last model vector or not. Default to True.

Attributes

n_data

Number of data values.

n_params

Number of model parameters.

Methods

__call__(model)

Evaluate simulation for a given model.

create_random(n_data, n_params, *[, seed])

Create a linear regressor with a random matrix.

jacobian(model)

Jacobian matrix for a given model.

Notes

Given the matrix \(\mathbf{X}\), the linear regressor simulation computes the data vector \(\mathbf{y}\) for a given model vector \(\mathbf{m}\) as follows:

\[\mathbf{y} = \mathbf{X} \cdot \mathbf{m}\]

Attributes#

LinearRegressor.n_data#
LinearRegressor.n_params#

Methods#

Methods documentation

LinearRegressor.__call__(model)#

Evaluate simulation for a given model.

Parameters:
model(n_params) array

Array with model values.

Returns:
(n_data)

Array with predicted data values for the given model.


classmethod LinearRegressor.create_random(n_data, n_params, *, seed=None, **kwargs)#

Create a linear regressor with a random matrix.

Parameters:
n_dataint

Number of data values that the simulation will generate.

n_paramsint

Number of elements in the model vector.

seedint or None, optional

Random seed or random state used to generate the matrix.

**kwargs

Keyword arguents passed to the constructor of LinearRegressor.


LinearRegressor.jacobian(model)#

Jacobian matrix for a given model.

Parameters:
model(n_params) array

Array with model values.

Returns:
(n_data, n_params) array or LinearOperator

Jacobian matrix as a dense or sparse array, or as a LinearOperator.