Source code for tempor.benchmarks.utils

"""Any utilities for the ``benchmark`` package directory."""

from typing import Tuple

import numpy as np


[docs]def generate_score(metric: np.ndarray) -> Tuple[float, float]: """Return score as mean and confidence interval using the 1.96 rule: ``(mean, 1.96 * std / sqrt(n))``. See e.g. https://math.stackexchange.com/a/1572814. Args: metric (np.ndarray): Input metric. Returns: Tuple[float, float]: The score as ``(mean, confidence interval)``. """ percentile_val = 1.96 return (float(np.mean(metric)), percentile_val * np.std(metric) / np.sqrt(len(metric)))