Covariance Matrices#

Covariance matrices are used in FIPS to represent uncertainty in the data provided to the inverse problem.

CovarianceMatrix#

Constructor#

CovarianceMatrix(data[, name, index, ...])

Represents a symmetric Covariance Matrix.

Attributes and underlying data#

CovarianceMatrix.name

Name of the structure, used for error messages and block naming.

CovarianceMatrix.data

The underlying data, which must be numeric and non-NaN.

CovarianceMatrix.index

Return the index of the underlying data.

CovarianceMatrix.columns

Return the columns of the underlying DataFrame.

CovarianceMatrix.shape

Return the shape of the underlying data.

CovarianceMatrix.values

Return values as numpy array or sparse matrix.

CovarianceMatrix.variances

Returns the variances (diagonal elements) of the covariance matrix.

CovarianceMatrix.blocks

Accessor for retrieving MatrixBlock instances from the Matrix.

Conversion#

CovarianceMatrix.copy([deep])

Create a copy of the structure.

CovarianceMatrix.to_frame()

Get the underlying DataFrame data.

CovarianceMatrix.to_numpy()

Get the underlying data as a NumPy array.

Reindexing / selection / label manipulation#

CovarianceMatrix.xs(key[, axis, level, ...])

Cross-select data based on index/column values.

CovarianceMatrix.reindex(index[, columns, ...])

Return a new instance with data reindexed to the specified index and columns.

CovarianceMatrix.round_index(decimals[, ...])

Round float indices on the specified axis to given decimals.

Serialization#

CovarianceMatrix.from_file(path)

Load object from a pickle file.

CovarianceMatrix.to_file(path)

Save object to a pickle file.

Sparse support#

CovarianceMatrix.is_sparse

True if the internal DataFrame uses pandas sparse storage.

CovarianceMatrix.to_sparse([threshold])

Return a copy with sparse internal storage.

CovarianceMatrix.to_dense()

Return a copy with dense internal storage.

Computations#

CovarianceMatrix.force_symmetry([keep])

Force the matrix to be perfectly symmetric by copying one triangle to the other.

ErrorComponents#

ErrorComponent(name, variances)

Abstract base class for error components in covariance matrices.

DiagonalError(name, variances)

Error component that produces diagonal covariance matrices.

BlockDecayError(name, variances, groupers, ...)

Error component with block-structured correlation decay.

KroneckerError(name, variances, marginal_kernels)

Builds a full covariance matrix for a strict grid.

Build covariance matrix#

ErrorComponent.build(index, **kwargs)

Must return a pd.DataFrame with the given index on both rows and columns.

Binary operations#

ErrorComponent.__add__(other)

Add error components to create a CovarianceBuilder.

CovarianceBuilder#

Constructor#

CovarianceBuilder(components)

Builds covariance matrices by combining multiple error components.

Build covariance matrix#

CovarianceBuilder.build(index[, sparse])

Build and sum all error components into a single DataFrame.

Binary operations#

CovarianceBuilder.__add__(other)

Add error components or builders together.

CovarianceBuilder.__radd__(other)

Right-hand addition for error components.