> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Rolling

> systematica.utils.rolling

## `rolling_reduce_pairs_1d_nb`

```python theme={null}
rolling_reduce_pairs_1d_nb(
    arr: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func_nb: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to a 2D array containing pairs of values.

**Parameters**:

| Name             | Type           | Default | Description                                                                                                |
| ---------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr`            | `Array2d`      | `--`    | Input 2D array where each row contains a pair of values.                                                   |
| `window`         | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`           | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func_nb` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`           | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func_nb`.                                                          |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_pairs_two_1d_nb`

```python theme={null}
rolling_reduce_pairs_two_1d_nb(
    arr1: numpy.ndarray,
    arr2: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func_nb: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to two 2D arrays containing pairs of
values.

**Parameters**:

| Name             | Type           | Default | Description                                                                                                |
| ---------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr1`           | `Array2d`      | `--`    | First input 2D array where each row contains a pair of values.                                             |
| `arr2`           | `Array2d`      | `--`    | Second input 2D array where each row contains a pair of values.                                            |
| `window`         | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`           | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func_nb` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`           | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func_nb`.                                                          |

**Raises**:

| Type         | Description                                  |
| ------------ | -------------------------------------------- |
| `ValueError` | If `arr1` and `arr2` have different lengths. |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_arr_1d_nb`

```python theme={null}
rolling_reduce_arr_1d_nb(
    arr: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func_nb: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to an array using vectorization.

**Parameters**:

| Name             | Type           | Default | Description                                                                                                |
| ---------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr`            | `Array1d`      | `--`    | Input 1D array.                                                                                            |
| `window`         | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`           | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func_nb` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`           | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func_nb`.                                                          |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_pairs_1d`

```python theme={null}
rolling_reduce_pairs_1d(
    arr: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to a 2D array containing pairs of values
(non-Numba version).

**Parameters**:

| Name          | Type           | Default | Description                                                                                                |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr`         | `Array2d`      | `--`    | Input 2D array where each row contains a pair of values.                                                   |
| `window`      | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`        | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`        | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func_nb`.                                                          |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_pairs_two_1d`

```python theme={null}
rolling_reduce_pairs_two_1d(
    arr1: numpy.ndarray,
    arr2: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to two 2D arrays containing pairs of
values (non-Numba version).

**Parameters**:

| Name          | Type           | Default | Description                                                                                                |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr1`        | `Array2d`      | `--`    | First input 2D array where each row contains a pair of values.                                             |
| `arr2`        | `Array2d`      | `--`    | Second input 2D array where each row contains a pair of values.                                            |
| `window`      | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`        | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`        | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func_nb`.                                                          |

**Raises**:

| Type         | Description                                  |
| ------------ | -------------------------------------------- |
| `ValueError` | If `arr1` and `arr2` have different lengths. |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_arr_1d`

```python theme={null}
rolling_reduce_arr_1d(
    arr: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to a 1D array (non-Numba version).

**Parameters**:

| Name          | Type           | Default | Description                                                                                                |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr`         | `Array1d`      | `--`    | Input 1D array.                                                                                            |
| `window`      | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`        | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`        | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func`.                                                             |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |

## `rolling_reduce_arr`

```python theme={null}
rolling_reduce_arr(
    arr: numpy.ndarray,
    window: int,
    minp: int,
    reduce_func: Callable[[numpy.ndarray, Any], str | float | int | complex | bool | object | numpy.generic],
    *args,
) ‑> numpy.ndarray
```

Apply a rolling reduction function to a 2D array (non-Numba version).

**Parameters**:

| Name          | Type           | Default | Description                                                                                                |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `arr`         | `Array1d`      | `--`    | Input 1D array.                                                                                            |
| `window`      | `int`          | `--`    | Rolling window size.                                                                                       |
| `minp`        | `int`          | `--`    | Minimum number of non-NaN observations required within the window. If None, defaults to `window`.          |
| `reduce_func` | `ReduceFunc`   | `--`    | Numba-compiled function that takes an array slice and additional arguments. it must return a single value. |
| `args`        | `tp.ArgsTaker` | `--`    | Additional arguments to pass to `reduce_func`.                                                             |

**Returns**:

| Type      | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `Array1d` | Output 1D array containing the result of the rolling reduction. |
