bijx.moving_average

bijx.moving_average(x, window=10)[source]

Compute moving average of a 1D array.

Applies a sliding window average to smooth noisy signals or time series. For arrays shorter than the window size, returns the overall mean.

Parameters:
  • x (Array) – Input 1D array to smooth.

  • window (int) – Size of the moving average window.

Returns:

Smoothed array with length max(1, len(x) - window + 1).

Example

>>> x = jnp.array([1, 2, 3, 4, 5])
>>> smoothed = moving_average(x, window=3)
>>> # Returns [2.0, 3.0, 4.0] (averages of [1,2,3], [2,3,4], [3,4,5])