Skip to content

komm.sampling_rate_compress

Performs sampling rate compression (downsampling). For a given input $x[n]$, the output is $$ y[n] = x[n M + \Delta], $$ where $M$ is the compression factor and $\Delta \in [0:M)$ is the offset for the first selected element. In words, the compressor extracts every $M$-th element starting from the offset $\Delta$ along the specified axis. For more details, see OS99, Sec. 4.6.1.

Parameters:

  • input (ArrayLike)

    The input array $x[n]$ to be compressed.

  • factor (int)

    The compression factor $M$.

  • offset (int)

    The offset $\Delta$. Must satisfy $\Delta \in [0:M)$.

  • axis (int)

    The axis along which to extract elements. Default is the last axis.

Returns:

  • output (NDArray[Any])

    The compressed array $y[n]$.

Examples:

>>> komm.sampling_rate_compress(
...    [[11, 12, 13, 14, 15],
...     [16, 17, 18, 19, 20]],
...    factor=3,
... )
array([[11, 14],
       [16, 19]])
>>> komm.sampling_rate_compress(
...    [[11, 12, 13, 14, 15],
...     [16, 17, 18, 19, 20]],
...    factor=3,
...    offset=1,
... )
array([[12, 15],
       [17, 20]])
>>> komm.sampling_rate_compress(
...     [[11, 12],
...      [13, 14],
...      [15, 16],
...      [17, 18],
...      [19, 20]],
...     factor=3,
...     axis=0,
... )
array([[11, 12],
       [17, 18]])