Clip array to a given value.
Similar to numpy.clip(), except that values less than threshmin or greater than threshmax are replaced by newval, instead of by threshmin and threshmax respectively.
Parameters : | a : array_like
threshmin : float, int or None, optional
threshmax : float, int or None, optional
newval : float or int, optional
|
---|---|
Returns : | out : ndarray
|
Examples
>>> a = np.array([9, 9, 6, 3, 1, 6, 1, 0, 0, 8])
>>> from scipy import stats
>>> stats.threshold(a, threshmin=2, threshmax=8, newval=-1)
array([-1, -1, 6, 3, -1, 6, -1, -1, -1, 8])