@@ -904,6 +904,24 @@ _median(v::AbstractArray{T}, ::Colon) where {T} = median!(copyto!(Array{T,1}(und
904904
905905median (r:: AbstractRange{<:Real} ) = mean (r)
906906
907+ """
908+ median(f, v)
909+
910+ Apply the function `f` to each element of collection `v`
911+ and then compute the median.
912+
913+ ```jldoctest
914+ julia> using Statistics
915+
916+ julia> median(√, [1, 3, 2])
917+ 1.4142135623730951
918+
919+ julia> median([√1, √3, √2])
920+ 1.4142135623730951
921+ ```
922+ """
923+ median (f:: Function , v) = median! (f .(v))
924+
907925"""
908926 quantile!([q::AbstractArray, ] v::AbstractVector, p; sorted=false, alpha::Real=1.0, beta::Real=alpha)
909927
@@ -1115,6 +1133,33 @@ julia> quantile(skipmissing([1, 10, missing]), 0.5)
11151133quantile (itr, p; sorted:: Bool = false , alpha:: Real = 1.0 , beta:: Real = alpha) =
11161134 quantile! (collect (itr), p, sorted= sorted, alpha= alpha, beta= beta)
11171135
1136+
1137+ """
1138+ quantile(f, v)
1139+
1140+ Apply the function `f` to each element of collection `v`
1141+ and then compute the quantile(s) at a specified probability
1142+ or vector or tuple of probabilities `p` on the interval [0,1].
1143+
1144+ ```jldoctest
1145+ julia> using Statistics
1146+
1147+ julia> quantile(√, [1, 3, 2], 0.3)
1148+ 1.248528137423857
1149+
1150+ julia> quantile([√1, √3, √2], 0.3)
1151+ 1.248528137423857
1152+
1153+ julia> quantile(√, [1, 3, 2], (0.3, 0.4, 0.5))
1154+ (1.248528137423857, 1.3313708498984762, 1.4142135623730951)
1155+
1156+ julia> quantile(.√[1, 3, 2], (0.3, 0.4, 0.5))
1157+ (1.248528137423857, 1.3313708498984762, 1.4142135623730951)
1158+ ```
1159+ """
1160+ quantile (f:: Function , v, p; sorted:: Bool = false , alpha:: Real = 1.0 , beta:: Real = alpha) =
1161+ quantile! (f .(v), p; sorted= sorted, alpha= alpha, beta= beta)
1162+
11181163quantile (v:: AbstractVector , p; sorted:: Bool = false , alpha:: Real = 1.0 , beta:: Real = alpha) =
11191164 quantile! (sorted ? v : Base. copymutable (v), p; sorted= sorted, alpha= alpha, beta= beta)
11201165
0 commit comments