nearest_values
- ketos.utils.nearest_values(x, i, n)[source]
Returns the n values nearest to index i from the array x.
Here, nearest refers to the position in the array, not the value.
- Args:
- x: numpy array
Input values
- i: int
Index
- n: int
Number of neighboring values
- Returns:
- y: numpy array
n values nearest to index i from the array x
- Example:
>>> from ketos.utils import nearest_values >>> >>> x = np.array([1.0, 4.0, 5.1, 6.0, 0.2, 0.3, 10.0]) >>> y = nearest_values(x=x, i=3, n=3) >>> print(y) [5.1 6. 0.2]