drytorch.utils.averages

Module containing classes and functions to average samples.

Functions

get_moving_average([decay, mass_coverage])

Return a moving average by specifying the decay.

get_trailing_mean(window_size)

Return a trailing average by specifying window size.

get_moving_average(decay: float = 0.9, mass_coverage: float = 0.99) Callable[[Sequence[float]], float][source]

Return a moving average by specifying the decay.

Parameters:
  • decay (float) – the closer to 0, the more the last elements have weight.

  • mass_coverage (float) – cumulative weight proportion before tail dropping.

Returns:

The moving average function.

Raises:
  • ValueError – if the decay is not between 0 and 1.

  • ValueError – if the mass_coverage is not between 1 - decay and 1.

Return type:

Callable[[Sequence[float]], float]

get_trailing_mean(window_size: int) Callable[[Sequence[float]], float][source]

Return a trailing average by specifying window size.

Parameters:

window_size (int) – number of items to aggregate.

Returns:

The windowed average function.

Raises:

ValueError if the window size is negative.

Return type:

Callable[[Sequence[float]], float]