lamatrix.models.spline#

Classes

SparseSpline([x_name, knots, order, priors, ...])

Spline([x_name, knots, order, priors, ...])

SplineMixins()

dSparseSpline(weights[, x_name, knots, ...])

dSpline(weights[, x_name, knots, order, ...])

class lamatrix.models.spline.SparseSpline(x_name: str = 'x', knots: ndarray = array([], dtype=float64), order: int = 3, priors=None, posteriors=None)[source]#

Bases: Spline

property arg_names#

Returns a set of the user defined strings for all the arguments that the design matrix requires.

bspline_basis(k, i, t, x)#

Calculate B-spline basis function value of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the basis function is evaluated

bspline_basis_derivative(k, i, t, x)#

Calculate the derivative of B-spline basis function of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the derivative is evaluated

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D spline in x

Parameters:

{} (np.ndarray) – Vector to create spline of

Returns:

X – Design matrix with shape (len(x), self.nvectors)

Return type:

np.ndarray

property equation#

Provides the equation for the model in latex.

If accessed within a jupyter instance will return the equation in displayed latex, otherwise will return the equation in raw latex.

evaluate(**kwargs)#

Given an input set of arguments, will evaluate the model with the current best fit weights.

fit(data: ndarray[Any, dtype[_ScalarType_co]], errors: ndarray[Any, dtype[_ScalarType_co]] | None = None, mask: ndarray[Any, dtype[_ScalarType_co]] | None = None, **kwargs)#

Fit the design matrix of this model object.

Executing this function will update the posteriors argument to the best fit posteriors.

Parameters:
  • data (np.ndarray) – Input data to fit

  • errors (np.ndarray, optional) – Errors on the input data

  • mask (np.ndarray, optional) – Mask to apply when fitting. Values where mask is False will not be used during the fit.

property nvectors#

Returns the number of vectors required to build the object.

sample(**kwargs)#

Given an input set of arguments, will evaluate the model with a sample of the best fit weights drawn from the posteriors.

save(filename: str)#
property spline_equation#
to_gradient(weights=None, priors=None)[source]#
to_latex()#
property width#

Returns the width of the design matrix once built.

class lamatrix.models.spline.Spline(x_name: str = 'x', knots: ndarray = array([], dtype=float64), order: int = 3, priors=None, posteriors=None)[source]#

Bases: MathMixins, SplineMixins, LatexMixins, IOMixins, Model

property arg_names#

Returns a set of the user defined strings for all the arguments that the design matrix requires.

bspline_basis(k, i, t, x)#

Calculate B-spline basis function value of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the basis function is evaluated

bspline_basis_derivative(k, i, t, x)#

Calculate the derivative of B-spline basis function of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the derivative is evaluated

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D spline in x

Parameters:

{} (np.ndarray) – Vector to create spline of

Returns:

X – Design matrix with shape (len(x), self.nvectors)

Return type:

np.ndarray

property equation#

Provides the equation for the model in latex.

If accessed within a jupyter instance will return the equation in displayed latex, otherwise will return the equation in raw latex.

evaluate(**kwargs)#

Given an input set of arguments, will evaluate the model with the current best fit weights.

fit(data: ndarray[Any, dtype[_ScalarType_co]], errors: ndarray[Any, dtype[_ScalarType_co]] | None = None, mask: ndarray[Any, dtype[_ScalarType_co]] | None = None, **kwargs)#

Fit the design matrix of this model object.

Executing this function will update the posteriors argument to the best fit posteriors.

Parameters:
  • data (np.ndarray) – Input data to fit

  • errors (np.ndarray, optional) – Errors on the input data

  • mask (np.ndarray, optional) – Mask to apply when fitting. Values where mask is False will not be used during the fit.

property nvectors#

Returns the number of vectors required to build the object.

sample(**kwargs)#

Given an input set of arguments, will evaluate the model with a sample of the best fit weights drawn from the posteriors.

save(filename: str)#
property spline_equation#
to_gradient(weights=None, priors=None)[source]#
to_latex()[source]#
property width#

Returns the width of the design matrix once built.

class lamatrix.models.spline.dSparseSpline(weights: List, x_name: str = 'x', knots: ndarray = array([], dtype=float64), order: int = 3, priors=None, posteriors=None)[source]#

Bases: dSpline

property arg_names#

Returns a set of the user defined strings for all the arguments that the design matrix requires.

bspline_basis(k, i, t, x)#

Calculate B-spline basis function value of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the basis function is evaluated

bspline_basis_derivative(k, i, t, x)#

Calculate the derivative of B-spline basis function of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the derivative is evaluated

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Returns a design matrix, given inputs listed in self.arg_names.

property equation#

Provides the equation for the model in latex.

If accessed within a jupyter instance will return the equation in displayed latex, otherwise will return the equation in raw latex.

evaluate(**kwargs)#

Given an input set of arguments, will evaluate the model with the current best fit weights.

fit(data: ndarray[Any, dtype[_ScalarType_co]], errors: ndarray[Any, dtype[_ScalarType_co]] | None = None, mask: ndarray[Any, dtype[_ScalarType_co]] | None = None, **kwargs)#

Fit the design matrix of this model object.

Executing this function will update the posteriors argument to the best fit posteriors.

Parameters:
  • data (np.ndarray) – Input data to fit

  • errors (np.ndarray, optional) – Errors on the input data

  • mask (np.ndarray, optional) – Mask to apply when fitting. Values where mask is False will not be used during the fit.

property nvectors#

Returns the number of vectors required to build the object.

sample(**kwargs)#

Given an input set of arguments, will evaluate the model with a sample of the best fit weights drawn from the posteriors.

property width#

Returns the width of the design matrix once built.

class lamatrix.models.spline.dSpline(weights: List, x_name: str = 'x', knots: ndarray = array([], dtype=float64), order: int = 3, priors=None, posteriors=None)[source]#

Bases: MathMixins, SplineMixins, Model

property arg_names#

Returns a set of the user defined strings for all the arguments that the design matrix requires.

bspline_basis(k, i, t, x)#

Calculate B-spline basis function value of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the basis function is evaluated

bspline_basis_derivative(k, i, t, x)#

Calculate the derivative of B-spline basis function of k-th order.

k : order of the basis function (degree + 1) i : index of the basis function t : array of knot positions x : position where the derivative is evaluated

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Returns a design matrix, given inputs listed in self.arg_names.

property equation#

Provides the equation for the model in latex.

If accessed within a jupyter instance will return the equation in displayed latex, otherwise will return the equation in raw latex.

evaluate(**kwargs)#

Given an input set of arguments, will evaluate the model with the current best fit weights.

fit(data: ndarray[Any, dtype[_ScalarType_co]], errors: ndarray[Any, dtype[_ScalarType_co]] | None = None, mask: ndarray[Any, dtype[_ScalarType_co]] | None = None, **kwargs)#

Fit the design matrix of this model object.

Executing this function will update the posteriors argument to the best fit posteriors.

Parameters:
  • data (np.ndarray) – Input data to fit

  • errors (np.ndarray, optional) – Errors on the input data

  • mask (np.ndarray, optional) – Mask to apply when fitting. Values where mask is False will not be used during the fit.

property nvectors#

Returns the number of vectors required to build the object.

sample(**kwargs)#

Given an input set of arguments, will evaluate the model with a sample of the best fit weights drawn from the posteriors.

property width#

Returns the width of the design matrix once built.