(self, new_value: float)
return (self._sum + self._correction) / self._window_size
Computes the moving window average in O(1) time.

    Args:
      new_value: The new value to enter the moving window.

    Returns:
      The average of the values in the window.
Computes the moving window average in O(1) time.
Computes the moving window average in O ( 1 ) time .
def calculate_average(self, new_value: float) -> float:
    """Computes the moving window average in O(1) time.

    Args:
      new_value: The new value to enter the moving window.

    Returns:
      The average of the values in the window.

    """
    deque_len = len(self._value_deque)
    if deque_len < self._value_deque.maxlen:
      pass
    else:
      # The left most value to be subtracted from the moving sum.
      self._neumaier_sum(-self._value_deque[0])

    self._neumaier_sum(new_value)
    self._value_deque.append(new_value)

    return (self._sum + self._correction) / self._window_size
def calculate_average ( self , new_value : float ) -> float : deque_len = len ( self . _value_deque ) if deque_len < self . _value_deque . maxlen : pass else : # The left most value to be subtracted from the moving sum. self . _neumaier_sum ( - self . _value_deque [ 0 ] ) self . _neumaier_sum ( new_value ) self . _value_deque . append ( new_value ) return ( self . _sum + self . _correction ) / self . _window_size