NormInducedMetric#
- class skfda.misc.metrics.NormInducedMetric(norm)[source]#
Metric induced by a norm.
Given a norm \(\| \cdot \|: X \rightarrow \mathbb{R}\), returns the metric \(d: X \times X \rightarrow \mathbb{R}\) induced by the norm:
\[d(f,g) = \|f - g\|\]- Parameters:
norm (Norm[VectorType]) – Norm used to induce the metric.
Examples
Computes the \(\mathbb{L}^2\) distance between an object containing functional data corresponding to the function \(y(x) = x\) defined over the interval [0, 1] and another one containing data of the function \(y(x) = x/2\).
Firstly we create the functional data.
>>> import skfda >>> import numpy as np >>> from skfda.misc.metrics import l2_norm, NormInducedMetric >>> >>> x = np.linspace(0, 1, 1001) >>> fd = skfda.FDataGrid([x], x) >>> fd2 = skfda.FDataGrid([x/2], x)
To construct the \(\mathbb{L}^2\) distance it is used the \(\mathbb{L}^2\) norm wich it is used to compute the distance.
>>> l2_distance = NormInducedMetric(l2_norm) >>> d = l2_distance(fd, fd2) >>> float(d[0]) 0.288...
Methods