Metrics#

This module contains multiple functional distances and norms.

Lp Spaces#

The following classes compute the norms and metrics used in Lp spaces. One first has to create an instance for the class, specifying the desired value for p, and use this instance to evaluate the norm or distance over functional data objects.

skfda.misc.metrics.LpNorm(p[, vector_norm])

Norm of all the observations in a FDataGrid object.

skfda.misc.metrics.LpDistance(p[, vector_norm])

Lp distance for functional data objects.

As the \(L_1\), \(L_2\) and \(L_{\infty}\) norms are very common in FDA, instances for these have been created, called respectively l1_norm, l2_norm and linf_norm. The same is true for metrics, having l1_distance, l2_distance and linf_distance already created.

The following functions are wrappers for convenience, in case that one only wants to evaluate the norm/metric for a value of p. These functions cannot be used in objects or methods that require a norm or metric, as the value of p must be explicitly passed in each call.

skfda.misc.metrics.lp_norm(vector, *, p[, ...])

Calculate the norm of all the observations in a FDataGrid object.

skfda.misc.metrics.lp_distance(fdata1, ...)

Lp distance for FDataGrid objects.

Angular distance#

The angular distance (using the normalized “angle” between functions given by the inner product) is also available, and useful in some contexts.

skfda.misc.metrics.angular_distance

Calculate the angular distance between two objects.

Elastic distances#

The following functions implements multiple distances used in the elastic analysis and registration of functional data.

skfda.misc.metrics.fisher_rao_distance

Compute the Fisher-Rao distance between two functional objects.

skfda.misc.metrics.fisher_rao_amplitude_distance(...)

Compute the Fisher-Rao amplitude distance between two functional objects.

skfda.misc.metrics.fisher_rao_phase_distance(...)

Compute the Fisher-Rao phase distance between two functional objects.

Mahalanobis distance#

The following class implements a functional version of the Mahalanobis distance:

skfda.misc.metrics.MahalanobisDistance([...])

Functional Mahalanobis distance.

Metric induced by a norm#

If a norm has been defined, it is possible to construct a metric between two elements simply subtracting one from the other and computing the norm of the result. Such a metric is called the metric induced by the norm, and the \(Lp\) distance is an example of these. The following class can be used to construct a metric from a norm in this way:

skfda.misc.metrics.NormInducedMetric(norm)

Metric induced by a norm.

Pairwise metric#

Some tasks require the computation of all possible distances between pairs of objets. The following class can compute that efficiently:

skfda.misc.metrics.PairwiseMetric(metric)

Pairwise metric function.

Transformation metric#

Some metrics, such as those based in derivatives, can be expressed as a transformation followed by another metric:

skfda.misc.metrics.TransformationMetric(...)

Compute a distance after transforming the data.