Welcome to gator’s documentation!

gator (pronounced “gā-tər”) is a python package which propagates observational uncertainties through linear-algebraic transformations

Installation

gator can be pip installed!

Example Usage

import numpy as np
from sklearn.datasets import make_spd_matrix

n_orig = 10
n_final = 4

obs = np.random.randn(n_orig)
print(obs)

obs_covar = make_spd_matrix(n_orig)
new_param_space_covar = make_spd_matrix(n_orig)
evals, evecs = np.linalg.eigh(new_param_space_covar)
tfm = evecs[:, ::-1][:, :n_final]
obs_tfm = obs @ tfm
obs_covar_tfm = propagate_varmat(obs_covar, tfm)

print(obs_covar_tfm)

gator’s functions

exception gator.gator.TransformationError[source]

Exception denoting an error in linear transformation

gator.gator.propagate_varmat(varmat, tmat)[source]

Propagate variance-covariance matrix through linear transformation

Executes pre- and post-multiplication of a variance-covariance matrix by a transformation matrix

Parameters:
  • varmat (array-like) – 2D variance-covariance matrix with shape (n, n)
  • tmat (array-like) – 2D transformation matrix with shape (n, p), which transforms a vector of len n to a vector of len p
Returns:

new_varmat – 2D variance-covariance matrix with shape (p, p)

Return type:

array-like

gator.gator.propagate_varmats(varmats, tmat, axis=-1)[source]

Propagate a series of variance matrices through a single linear transformation

Executes vectorized pre- and post-multiplication of a variance-covariance matrix by a transformation matrix

Parameters:
  • varmats (array-like) – series of 2D variance-covariance matrix with shape (n, n), all stacked along one or more axes
  • tmat (array-like) – 2D transformation matrix with shape (n, p), which transforms a vector of len n to a vector of len p
  • axis ({int, sequence}, optional) – the axis (or axes) along with the matrix-multiplication is broadcast (the default is -1, which means the variance matrices are stacked along the final axis)

Indices and tables