lamatrix.models.gaussian#

Model objects for Gaussian types of models

Classes

Gaussian([x_name, sigma, mu, priors, posteriors])

Gaussian2D([x_name, y_name, priors, ...])

dGaussian(weights[, x_name, sigma, mu, ...])

dGaussian2D(weights[, x_name, y_name, ...])

dlnGaussian(mu, sigma[, x_name, priors, ...])

dlnGaussian2D(mu_x, sigma_x, mu_y, sigma_y)

lnGaussian([x_name, priors, posteriors, ...])

lnGaussian2D([x_name, y_name, priors, ...])

class lamatrix.models.gaussian.Gaussian(x_name: str = 'x', sigma: float = 1.0, mu: float = 0.0, priors=None, posteriors=None)[source]#

Bases: MathMixins, LatexMixins, IOMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D polynomial in x_name.

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.

property posterior_amplitude#
property prior_amplitude#
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)#
to_gradient(weights=None, priors=None)[source]#
to_latex()#
property width#

Returns the width of the design matrix once built.

class lamatrix.models.gaussian.Gaussian2D(x_name: str = 'x', y_name: str = 'y', priors=None, posteriors=None, sigma_x=1, sigma_y=1, mu_x=0, mu_y=0, rho=0.0)[source]#

Bases: MathMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D polynomial in x_name.

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 fit_amplitude#
property nvectors#

Returns the number of vectors required to build the object.

property prior_amplitude#
sample(**kwargs)#

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

to_gradient(weights=None, priors=None)[source]#
property width#

Returns the width of the design matrix once built.

class lamatrix.models.gaussian.dGaussian(weights: List, x_name: str = 'x', sigma: float = 1.0, mu: float = 0.0, priors=None, posteriors=None)[source]#

Bases: MathMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D polynomial in x_name.

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.

property posterior_amplitude#
property prior_amplitude#
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.gaussian.dGaussian2D(weights: List, x_name: str = 'x', y_name: str = 'y', priors=None, posteriors=None, sigma_x=1, sigma_y=1, mu_x=0, mu_y=0, rho=0.5)[source]#

Bases: MathMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#

Build a 1D polynomial in x_name.

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 fit_amplitude#
property nvectors#

Returns the number of vectors required to build the object.

property prior_amplitude#
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.gaussian.dlnGaussian(mu: float, sigma: float, x_name: str = 'x', priors=None, posteriors=None)[source]#

Bases: MathMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#
Parameters:

x (np.ndarray) – Vector to create ln Gaussian of

Returns:

X – Design matrix with shape (len(x), 2)

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 width#

Returns the width of the design matrix once built.

class lamatrix.models.gaussian.dlnGaussian2D(mu_x: float, sigma_x: float, mu_y: float, sigma_y: float, x_name: str = 'x', y_name: str = 'y', priors=None, posteriors=None)[source]#

Bases: MathMixins, Model

property arg_names#

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

copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#
Parameters:

x (np.ndarray) – Vector to create ln Gaussian of

Returns:

X – Design matrix with shape (len(x), 2)

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 width#

Returns the width of the design matrix once built.

class lamatrix.models.gaussian.lnGaussian(x_name: str = 'x', priors=None, posteriors=None, prior_A=None, prior_mu=None, prior_sigma=None)[source]#

Bases: MathMixins, Model

property A#
property arg_names#

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

coefficients_to_gaussian_parameters(distributions)[source]#
copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#
Parameters:

x (np.ndarray) – Vector to create ln Gaussian of

Returns:

X – Design matrix with shape (len(x), 2)

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.

gaussian_parameters_to_coefficients(distributions)[source]#
property mu#
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 sigma#
to_gradient(sigma=None, mu=None, priors=None)[source]#
to_linear_space()[source]#
property width#

Returns the width of the design matrix once built.

class lamatrix.models.gaussian.lnGaussian2D(x_name: str = 'x', y_name: str = 'y', priors=None, posteriors=None, prior_A=None, prior_mu_x=None, prior_sigma_x=None, prior_mu_y=None, prior_sigma_y=None)[source]#

Bases: MathMixins, Model

property A#
property arg_names#

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

coefficients_to_gaussian_parameters(distributions)[source]#
copy()#

Returns a deep copy of self.

design_matrix(**kwargs)[source]#
Parameters:

x (np.ndarray) – Vector to create ln Gaussian of

Returns:

X – Design matrix with shape (len(x), 2)

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.

gaussian_parameters_to_coefficients(distributions)[source]#
property mu_x#
property mu_y#
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 sigma_x#
property sigma_y#
to_gradient(sigma_x=None, mu_x=None, sigma_y=None, mu_y=None, priors=None)[source]#
to_linear_space()[source]#
property width#

Returns the width of the design matrix once built.