pyhctsa.operations.distribution.cv

pyhctsa.operations.distribution.cv(x, k=1)

Calculate the coefficient of variation of order k.

The coefficient of variation (CV) of order \(k\) is defined as

\[\left( \frac{\sigma}{\mu} \right)^{k},\]

where \(\sigma\) is the standard deviation and \(\mu\) is the mean of the input data. It is negative (for odd \(k\)) when the mean is negative, and undefined when the mean is zero, so NaN is returned when the mean is at the level of rounding error relative to the spread (\(|\mu| < 10^{-10}\sigma\), as for a centered or z-scored series).

Parameters:
x : array-like

Input time series or data vector.

k : int, optional

Order of the coefficient of variation. Default is 1.

Returns:

The coefficient of variation of order \(k\), or NaN if the mean is zero up to rounding error.

Return type:

float