def minmax(X):
"""
Returns the MinMax Semivariance of sample X.
X has to be an even-length array of point pairs like: x1, x1+h, x2, x2+h, ..., xn, xn+h.
:param X:
:return:
"""
_X = np.asarray(X)
if any([isinstance(_, list) or isinstance(_, np.ndarray) for _ in _X]):
return [minmax(_) for _ in _X]
# check even
if len(_X) % 2 > 0:
raise ValueError('The sample does not have an even length: {}'.format(_X))
return (np.nanmax(_X) - np.nanmin(_X)) / np.nanmean(_X)
评论列表
文章目录