JuliaStats / Statistics.jl

The Statistics stdlib that ships with Julia.
https://juliastats.org/Statistics.jl/dev/
Other
71 stars 40 forks source link

`cquantile` on iterables #158

Open yuvalwas opened 9 months ago

yuvalwas commented 9 months ago

Hello, It is a minor thing, but since it already exists, I thought it makes sense that cquantile would be defined for this case as well. To be specific, at the moment cquantile(rand(1000), 0.9) has no method, but it could return quantile(rand(1000), 0.1). Thanks

nalimilan commented 9 months ago

@devmotion Why did you transfer this to Statistics? cquantile lives in Distributions.jl, and quantile already accepts any iterator.

devmotion commented 9 months ago

Distributions only wants and implements quantile(::UnivariateDistribution, ::Real), and similarly only cquantile(::UnivariateDistribution, ::Real) is of interest there. But methods such as quantile(::AbstractArray, p) (with all its keyword arguments) do not belong in Distributions, and hence similarly IMO something like cquantile(::AbstractArray, ::Real) does not belong there but (if it is desired) next to where quantile(::AbstractArray, ::Real) is defined.

nalimilan commented 8 months ago

Got it. That makes sense, though I'm not totally convinced it's worth adding a function just to avoid typing 1-p. Do we know why that function judged useful enough to be added to Distributions in the first place?