fips.Kronecker#

class fips.Kronecker(*factors)[source]#

Bases: CorrelationModel

The product of correlation models on separate levels, kept as its factors.

The correlation of two labels is the product of the factors’ correlations of them. Each factor reads its own levels (no level is read by two) and is evaluated once, on the unique coordinates of its levels: the covariance is a KroneckerOperator, never the n x n matrix. The labels can be in any order and any subset of the product of the factors’ coordinates, but each label must have its own combination of them.

Parameters:

*factors (CorrelationModel) – Two or more models, each reading at least one level (so not Independent). A Kronecker factor brings its own factors.

Raises:

ValueError – If fewer than two factors are given, a factor reads no level, or two factors read the same level.

Examples

>>> import pandas as pd
>>> from fips import Exponential, Kronecker, Space
>>> labels = pd.MultiIndex.from_product(
...     [pd.date_range("2024-01-01", periods=3), [40.0, 40.5], [-112.0]],
...     names=["time", "lat", "lon"],
... )
>>> model = Kronecker(
...     Exponential("time", "2D"),
...     Exponential(["lat", "lon"], 50.0, metric="haversine"),
... )
>>> S_0 = model.with_std(0.5).build(Space({"flux": labels}))
>>> S_0.data
<6x6 KroneckerOperator with dtype=float64>

Attributes

factors

The factors, each a model on its own levels.

levels

The levels the factors read, factor by factor.

Methods

correlation(coords)

Return the correlation between the rows of coords, as a dense matrix.

Inherited

From CorrelationModel: with_std