sample_sample_distance

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

Compute the sample-sample distance.

For a set of samples \(x_1, ..., x_N \in \mathbb{R}^d\), compute the set of dimension-normalized sample-sample distances \(E=(E_1, ..., E_N)\) given by

\[E_k = \frac{1}{dN} \sum_{n=1}^N \| x_k - x_n \|_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.

  • 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-sample distances \(E=(E_1, ..., E_N)\).

Return type

np.ndarray

Examples

>>> import numpy as np
>>> fake_samples = np.arange(0, 300).reshape((100, 3))
>>> rmse = sample_sample_distance(fake_samples, p=2)
>>> print(rmse.shape)
(100,)
>>> print(np.round(np.mean(rmse), 1))
57.7