content/commands/tdigest.rank.md
Returns, for each floating-point input value, the estimated rank of the value (the number of observations in the sketch that are smaller than the value + half the number of observations that are equal to the value). Multiple ranks can be retrieved in a single call.
is the key name for an existing t-digest sketch.
</details> <details open><summary><code>value</code></summary>is the input value for which the rank should be estimated.
</details>{{< highlight bash >}} redis> TDIGEST.CREATE s COMPRESSION 1000 OK redis> TDIGEST.ADD s 10 20 30 40 50 60 OK redis> TDIGEST.RANK s 0 10 20 30 40 50 60 70
{{< highlight bash >}} redis> TDIGEST.CREATE s COMPRESSION 1000 OK redis> TDIGEST.ADD s 10 10 10 10 20 20 OK redis> TDIGEST.RANK s 10 20
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported"><nobr>✅ Flexible & Annual</nobr></span> <span title="Supported">✅ Free & Fixed</nobr></span> | |
{{< multitabs id="tdigest-rank-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
[Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integers]({{< relref "/develop/reference/protocol-spec#integers" >}}) populated with rank_1, rank_2, ..., rank_V:
-1 when value is smaller than the value of the smallest observation.value is larger than the value of the largest observation.value + half the observations equal to value).0 is the rank of the value of the smallest observation.
n-1 is the rank of the value of the largest observation, where n denotes the number of observations added to the sketch.
All values are -2 if the sketch is empty.
[Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: the given key does not exist or is of an incorrect type, quantile parsing errors, or incorrect number of arguments.
-tab-sep-
One of the following:
[Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integers]({{< relref "/develop/reference/protocol-spec#integers" >}}) populated with rank_1, rank_2, ..., rank_V:
-1 when value is smaller than the value of the smallest observation.value is larger than the value of the largest observation.value + half the observations equal to value).0 is the rank of the value of the smallest observation.
n-1 is the rank of the value of the largest observation, where n denotes the number of observations added to the sketch.
All values are -2 if the sketch is empty.
[Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: the given key does not exist or is of an incorrect type, quantile parsing errors, or incorrect number of arguments.
{{< /multitabs >}}