@@ -29,6 +29,8 @@ Compute the mean of all elements in a collection.
2929
3030# Examples
3131```jldoctest
32+ julia> using Statistics
33+
3234julia> mean(1:20)
333510.5
3436
@@ -47,6 +49,8 @@ mean(itr) = mean(identity, itr)
4749Apply the function `f` to each element of collection `itr` and take the mean.
4850
4951```jldoctest
52+ julia> using Statistics
53+
5054julia> mean(√, [1, 2, 3])
51551.3820881233139908
5256
@@ -83,6 +87,8 @@ Apply the function `f` to each element of array `A` and take the mean over dimen
8387 This method requires at least Julia 1.3.
8488
8589```jldoctest
90+ julia> using Statistics
91+
8692julia> mean(√, [1, 2, 3])
87931.3820881233139908
8894
@@ -107,6 +113,8 @@ Compute the mean of `v` over the singleton dimensions of `r`, and write results
107113
108114# Examples
109115```jldoctest
116+ julia> using Statistics
117+
110118julia> v = [1 2; 3 4]
1111192×2 Array{Int64,2}:
112120 1 2
@@ -139,6 +147,8 @@ Compute the mean of an array over the given dimensions.
139147
140148# Examples
141149```jldoctest
150+ julia> using Statistics
151+
142152julia> A = [1 2; 3 4]
1431532×2 Array{Int64,2}:
144154 1 2
@@ -720,6 +730,8 @@ Compute the middle of a range, which consists of computing the mean of its extre
720730Since a range is sorted, the mean is performed with the first and last element.
721731
722732```jldoctest
733+ julia> using Statistics
734+
723735julia> middle(1:10)
7247365.5
725737```
@@ -733,6 +745,8 @@ Compute the middle of an array `a`, which consists of finding its
733745extrema and then computing their mean.
734746
735747```jldoctest
748+ julia> using Statistics
749+
736750julia> a = [1,2,3.6,10.9]
7377514-element Array{Float64,1}:
738752 1.0
@@ -782,6 +796,8 @@ equivalent to calculating mean of two median elements.
782796
783797# Examples
784798```jldoctest
799+ julia> using Statistics
800+
785801julia> median([1, 2, 3])
7868022.0
787803
@@ -803,7 +819,9 @@ median(itr) = median!(collect(itr))
803819Compute the median of an array along the given dimensions.
804820
805821# Examples
806- ```jldoctest
822+ ```jl
823+ julia> using Statistics
824+
807825julia> median([1 2; 3 4], dims=1)
8088261×2 Array{Float64,2}:
809827 2.0 3.0
@@ -838,6 +856,8 @@ for `k = 1:n` where `n = length(v)`. This corresponds to Definition 7 of Hyndman
838856
839857# Examples
840858```jldoctest
859+ julia> using Statistics
860+
841861julia> x = [3, 2, 1];
842862
843863julia> quantile!(x, 0.5)
@@ -950,6 +970,8 @@ for `k = 1:n` where `n = length(itr)`. This corresponds to Definition 7 of Hyndm
950970
951971# Examples
952972```jldoctest
973+ julia> using Statistics
974+
953975julia> quantile(0:20, 0.5)
95497610.0
955977
0 commit comments