FIX: ensures average is applied on last incomplete segment (PR #13472)

GitHub