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
- 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