Suppose I have a number of experiments, say 5, each of which consist of a 2x3 matrix of data. I can either organize these in a 2x3x5 array A, C
, or in a vector of 5 elements of 2x3 matrices (B
). For illustration:
# Organized in array
A = rand(2,3,5)
# Organized in vector
B = [A[:,:,i] for i in 1:size(A)[3]]
# Convert from vector to array
C = Array{Float64}(undef,size(B[1])...,length(B))
for i in 1:length(B)
C[:,:,i] = B[i]
end
Some questions:
 In the
Statistics
package, I assume that arraysA,C
(which are equal) qualify asAbstractArray
while the vectorB
qualifies asitr
or perhaps asAbstractVector
??
The following pairs of operations give the same answerâŚ
julia> mean(A,dims=3)[:,:] == mean(B)
true
julia> std(A,dims=3)[:,:] == std(B)
true
julia> var(A,dims=3)[:,:] == var(B)
true
However, if I want to compute median
, quantiles
, etc., things are differentâŚ
julia> median(A,dims=3)[:,:]
2Ă3 Array{Float64,2}:
0.831352 0.615277 0.481671
0.587861 0.531014 0.375483
julia> median(B)
ERROR: MethodError: no method matching isless(::Array{Float64,2}, ::Array{Float64,2})...
And for quantile
, neither quantile(B, 0.5)
nor quantile(A,0.5,dims=3)
work.

Why donât these functions admit/similar same arguments as
mean
,std
,var
? 
Is there a more elegant way to convert from vector
B
to arrayC
? [Something likehcat(B...,newdim=true)