def calculate_new_average(avg, N, new_val):
    """Calculate new average given a new value and an existing average.

    Args:
        avg: The old average value.
        N: The old number of data points averaged over.
        new_val: The new value to recalculate the average with.

    Returns:
        The new average value.
    """
    return (avg * N + new_val) / (N + 1)