Hello,
1. I can apply mean to an array of vectors, but doing the same for cov
produces an error.
2. I can apply cov to a matrix, which produces the covariance matrix
treating each row as an observation. Applying mean to the same matrix
produces a scalar average of all elements in the matrix.
This asymmetric treatment is counter-intuitive. What is the rationale?
Thanks!
n=10
A=Array(Vector,n)
for i=1:n
A[i]=randn(3)
end
println(mean(A))
println(cov(A)) #
produces an error
B=Array(Float64,n,3)
for i=1:n
B[i,:]=A[i]
end
println("mean:",mean(B)) #
produces average of all elements in B
println("covariance matrix:",cov(B)) #
produces covariance matrix of columns of B