**Use case**
Clickhouse version 21.4
```
SELECT
    quantileTiming(0.95)(key) AS timing,
    quantileExact(0.95)(key) AS exact,
    quantileTDigest(0.95)(key) AS tdigest
FROM
(
    SELECT
        9000 AS key,
        2 AS count
    UNION ALL
    SELECT
        3000,
        11
    UNION ALL
    SELECT
        1000,
        26
)
ARRAY JOIN range(count) AS s

Query id: addce63f-0b75-46e2-b896-712d66711fb0

┌─timing─┬─exact─┬──tdigest─┐
│   9000 │  9000 │ 8123.076 │
└────────┴───────┴──────────┘


SELECT
    quantileTiming(0.9)(key) AS timing,
    quantileExact(0.9)(key) AS exact,
    quantileTDigest(0.9)(key) AS tdigest
FROM
(
    SELECT key
    FROM
    (
        SELECT
            9000 AS key,
            2 AS count
        UNION ALL
        SELECT
            3000,
            11
        UNION ALL
        SELECT
            1000,
            26
    )
    ARRAY JOIN range(count) AS s
    ORDER BY key ASC
)

Query id: e92e3d07-3b97-4155-aa10-9a15544d9312

┌─timing─┬─exact─┬───tdigest─┐
│   3000 │  3000 │ 6323.0757 │
└────────┴───────┴───────────┘

```

Probably related: https://github.com/tdunning/t-digest/issues/154
{
        if (centroids.empty())
            return std::is_floating_point_v<ResultType> ? NAN : 0;
        compress();
        if (centroids.size() == 1)
            return centroids.front().mean;
        Float64 x = level * count;
        Float64 prev_x = 0;
        Count sum = 0;
        Value prev_mean = centroids.front().mean;
        for (const auto & c : centroids)
        {
            Float64 current_x = sum + c.count * 0.5;
            if (current_x >= x)
                return interpolate(x, prev_x, prev_mean, current_x, c.mean);
            sum += c.count;
            prev_mean = c.mean;
            prev_x = current_x;
        }
        return centroids.back().mean;
    }
    /** Get multiple quantiles (`size` parts).
      * levels - an array of levels of the desired quantiles. They are in a random order.
      * levels_permutation - array-permutation levels. The i-th position will be the index of the i-th ascending level in the `levels` array.
      * result - the array where the results are added, in order of `levels`,
      */
    template <typename ResultType>
    void getManyImpl(const Float64 * levels, const size_t * levels_permutation, size_t size, ResultType * result)