statistics.quantiles() is new in Python 3.8, replace it with custom implementation to preserve compatibility with older Python versions.