**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
}
                
                
                BetterFloat ql = (sum + l_count * 0.5) / count;
                BetterFloat err = ql * (1 - ql);
                
                BetterFloat qr = (sum + l_count + r->count * 0.5) / count;
                BetterFloat err2 = qr * (1 - qr);
                if (err > err2)
                    err = err2;
                BetterFloat k = count_epsilon_4 * err;
                /** The ratio of the weight of the glued column pair to all values is not greater,
                  *  than epsilon multiply by a certain quadratic coefficient, which in the median is 1 (4 * 1/2 * 1/2),
                  *  and at the edges decreases and is approximately equal to the distance to the edge * 4.
                  */
                if (l_count + r->count <= k)
                {
                    
                    
                    l_count += r->count;
                    l_mean += r->count * (r->mean - l_mean) / l_count; 
                    l->mean = l_mean;
                    l->count = l_count;
                }
                else
                {
                    
                    sum += l->count; 
                    ++l;