Ah. I misread your post. The explanation is that the computation of the
mean generalizes to the case where each element is a vector, but this is
not the case for the way we calculate the variance. It could be supported,
but then I think it would make most sense to generalize the variance and
not the covariance function.

2015-05-08 17:05 GMT-04:00 JPi <[email protected]>:

> Yes, the variance.
>
> But that doesn't explain why you can't get the covariance matrix of an
> array of vectors.
>
> On Friday, May 8, 2015 at 4:51:13 PM UTC-4, Andreas Noack wrote:
>>
>> Calculating the covariance requires two sequences of data points. Either
>> from two vectors or between the columns of a matrix. The mean is different
>> as it requires one sequence. What did you expect to get from the covariance
>> function of a vector? The variance?
>>
>> 2015-05-08 16:01 GMT-04:00 JPi <[email protected]>:
>>
>>> 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
>>>
>>>
>>>
>>>
>>

Reply via email to