fips.Matern#

class fips.Matern(levels, scale, nu=1.5, *, within=None, metric='euclidean')[source]#

Bases: _Decay

A Matérn correlation, of smoothness \(\nu\).

\[C(d) = \frac{2^{1-\nu}}{\Gamma(\nu)} \, r^\nu K_\nu(r), \qquad r = \sqrt{2\nu} \, d / \ell,\]

where \(K_\nu\) is the modified Bessel function of the second kind (Rasmussen and Williams 2006, eq. 4.14). \(\nu = 1/2\) is Exponential, and \(\nu \to \infty\) is Gaussian.

Parameters:
Raises:

ValueError – As Exponential, and if nu is not in (0, 50].

Examples

>>> import pandas as pd
>>> from fips import Matern
>>> coords = pd.DataFrame({"x": [0.0, 1.0]})
>>> Matern("x", 1.0, nu=0.5).correlation(coords).round(4)
array([[1.    , 0.3679],
       [0.3679, 1.    ]])

Attributes

metric

How the distance is measured, "euclidean", "haversine" or "chordal".

nu

The smoothness, 1/2 for the exponential and smoother as it grows.

scale

The length scale, a time for a datetime or timedelta level, else in the levels' units (km on the Earth).

within

The levels on which two labels must be the same to be correlated ("time.hour" is an attribute of a datetime level).

Methods

correlation(coords)

Return the correlation between the rows of coords, zero between groups (see CorrelationModel.correlation()).

Inherited

From CorrelationModel: levels, with_std