---
title: "ClikaRT::ops::quantile"
sidebar_label: "quantile"
description: "The q-th quantile of input along dim. q is a scalar or 1-D tensor of probabilities in [0, 1]. Absent dim flattens input first."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## quantile() {#quantile}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`quantile`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `q`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<int64_t>` `dim` `=` `std::nullopt`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`QuantileInterp`](./index.md#QuantileInterp) `interpolation` `=` [`QuantileInterp::Linear`](./index.md#QuantileInterp)<br />
)

</div>

The `q`-th quantile of `input` along `dim`.

`q` is a scalar or 1-D tensor of probabilities in `[0, 1]`. Absent `dim` flattens `input` first. The output prepends `q`'s shape to the reduced shape; `interpolation` picks the between-ranks strategy (`Linear` by default; see [`QuantileInterp`](./index.md#QuantileInterp) for the full set).

**Parameters**

- `input`: the input tensor; float dtype.
- `q`: probability level(s) in `[0, 1]`.
- `dim`: axis to reduce; absent = flatten.
- `keepdim`: keep the reduced axis as size 1; default false.
- `interpolation`: between-ranks strategy; default `Linear`.

**Returns:** the quantile values; `q`'s shape prepended to the reduced shape; dtype of `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when a `q` entry falls outside `[0, 1]` or `dim` is out of range.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4735

</div>
