Update median calculation
Summary: Simplifies the median calculation, and defends against edge cases that can cause crashes.
Test Plan: Should compute the same results as the previous median, and should not crash.
Reviewers: mutlaqja
Reviewed By: mutlaqja
Subscribers: kde-edu
Tags: KDE Edu
Differential Revision: https://phabricator.kde.org/D27880