lamatrix.models.spline#
Classes
|
|
|
|
|
|
|
|
|
- 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.
- property spline_equation#
- 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.
- property spline_equation#
- 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
.
- 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
.
- 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.