Back to Redis

TDIGEST.CDF

content/commands/tdigest.cdf.md

latest2.4 KB
Original Source

Returns, for each input value, an estimation of the floating-point fraction of (observations smaller than the given value + half the observations equal to the given value). Multiple fractions can be retrieved in a single call.

Required arguments

<details open><summary><code>key</code></summary>

is the key name for an existing t-digest sketch.

</details> <details open><summary><code>value</code></summary>

are the values for which the CDF (Cumulative Distribution Function) should be retrieved.

</details>

Examples

{{< highlight bash >}} redis> TDIGEST.CREATE t COMPRESSION 1000 OK redis> TDIGEST.ADD t 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 OK redis> TDIGEST.CDF t 0 1 2 3 4 5 6

  1. "0"
  2. "0.033333333333333333"
  3. "0.13333333333333333"
  4. "0.29999999999999999"
  5. "0.53333333333333333"
  6. "0.83333333333333337"
  7. "1" {{< / highlight >}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |

Return information

{{< multitabs id="tdigest-cdf-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) as floating-points, populated with fraction_1, fraction_2, ..., fraction_N. All values are nan if the given 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, value parsing errors, or an incorrect number of arguments.

-tab-sep-

One of the following:

  • [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [doubles]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) populated with fraction_1, fraction_2, ..., fraction_N. All values are nan if the given 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, value parsing errors, or an incorrect number of arguments.

{{< /multitabs >}}