pyhctsa.utils.z_score

pyhctsa.utils.z_score(x)

Z-score the input data vector.

This function standardizes the input array by removing the mean and scaling to unit variance (sample standard deviation, n - 1 in the denominator). It performs the z-scoring operation twice to reduce numerical error. The check for a constant series is scale-free: there is no threshold on the variance or range, so data of any scale (however small its units) is standardized.

Parameters:
x : array-like

Input data vector (1D array or list of numbers).

Returns:

The z-scored version of the input data.

Return type:

np.ndarray

Raises:
  • TypeError – If the input cannot be converted to a numeric array.

  • ValueError – If the input is empty, contains NaN or Inf, or is constant: all values equal, up to floating-point rounding at their own magnitude (a range of at most a few units in the last place of the largest absolute value), so that there is no variation to standardize.