pymovements.synthetic.step_function#

pymovements.synthetic.step_function(length: int, steps: list[int], values: list[float | tuple[float, ...]], start_value: float | tuple[float, ...] = 0, noise: float = 0) np.ndarray#

Create a synthetic eye gaze by using a simple step function.

Parameters:
  • length (int) – Length of the output sequence.

  • steps (list[int]) – Indices for each step to happen.

  • values (list[float | tuple[float, ...]]) – Array values to set at each step.

  • start_value (float | tuple[float, ...]) – Array value to start with. (default: 0)

  • noise (float) – If greater than zero, gaussian noise is scaled according to value and superimposed on the output array. (default: 0)

Returns:

Output signal

Return type:

np.ndarray

Raises:

ValueError – If steps not sorted in ascending order or length of steps not equal to length of values. If noise is negative.

Examples

>>> step_function(
...     length=10,
...     steps=[2, 5, 9],
...     values=[1., 2., 3.],
...     start_value=0,
... )
array([0., 0., 1., 1., 1., 2., 2., 2., 2., 3.], dtype=float32)
>>> # multi-channel example
>>> step_function(
...     length=10,
...     steps=[2, 5],
...     values=[(1., 2.), (3., 4.)],
...     start_value=(11., 22.),
... )
array([[11., 22.],
       [11., 22.],
       [ 1.,  2.],
       [ 1.,  2.],
       [ 1.,  2.],
       [ 3.,  4.],
       [ 3.,  4.],
       [ 3.,  4.],
       [ 3.,  4.],
       [ 3.,  4.]], dtype=float32)