sample_reference_distance

probnumeval.multivariate.sample_reference_distance(samples, reference, p=2)[source]

Compute the sample-reference distance.

For a set of samples \(x_1, ..., x_N \in \mathbb{R}^d\) and reference solution \(\xi \in \mathbb{R}^d\), compute the set of dimension-normalized sample-reference distances \(R=(R_1, ..., R_N)\) given by

\[R_k = \frac{1}{d} \| x_k - \xi \|_p\]

for \(1 \leq p \leq \infty\). For \(p=2\), the root mean-squared error is recovered.

Parameters
  • samples (ndarray) – Shape (N, d). Samples from the solution, evaluated at an end point.

  • reference (ndarray) – Shape (d,). Reference solution..

  • p (int) – Order of the underlying norm that shall be used. At least 1, at most infinity. Default is 2, which corresponds to the RMSE.

Returns

Shape (N,). Sample-reference distances \(R=(R_1, ..., R_N)\).

Return type

np.ndarray

Examples

>>> import numpy as np
>>> fake_samples = np.arange(0, 300).reshape((100, 3))
>>> fake_reference = np.arange(10, 13)
>>> rmse = sample_reference_distance(fake_samples, fake_reference, p=2)
>>> print(rmse.shape)
(100,)
>>> print(np.round(np.mean(rmse), 1))
80.2