The docstring of quantile
in the Statistics
module says:
quantile(itr, p; sorted=false)
Compute the quantile(s) of a collection
itr
at a specified probability or vector or tuple of
probabilitiesp
on the interval [0,1]. The keyword argumentsorted
indicates whether
itr
can be assumed to be sorted.
But itr
cannot actually be any iterable; only <:AbstractVector
or something that becomes that type after collect
, as seen in the “in-place” function quantile!
For instance, a Matrix
or more generally an AbstractArray{T,N}
where N > 1
is not accepted.
What would be the best way to calculate quantiles for such variables?
An obvious option is quantile(x[:], p)
, but this makes an unnecessary copy.
quantile(view(x,:), p)
would avoid the copy, but I don’t know if there something better.