cpp calculate 6x6 Covariance Matrix from two 1x3 arrays

207 Views Asked by At

Like title says, I am attempting to calculate the covariance matrix for two 1x3 arrays and get one 6x6 std::array in C++. I need some guidance with my understanding - have looked and not been able to see much in terms of clarity to answer my question.

I have two arrays each with 3 elements. Array 1 holds location data (x,y,z) and Array2 holds velocity data; we will call it (A,B,C)

Array1 = {x,y,z}

Array2 = {A,B,C}

and need to complete a Covariance matrix computing this into a 2d array[6][6]

I don't understand How I would get this.

I think my covariance formula is correct but still this would give me just an array[3][3].

cov = ( (Array1[n] - mean(Array1)) * (Array2[n] - mean(Array2)) ) / 3

\ 3 because its the number of values in each array.

0

There are 0 best solutions below