Bhanu Teja Pogiri
Bhanu Teja Pogiri

Reputation: 11

Difference between covariance using outer product and covariance using inner product?

I was going through a course, where in i am calculating covariance using inner product and outer product. For cov using inner product, I've used below code:

inner_product = np.dot(numerical_data_centered.T, numerical_data_centered)

cov_matrix_inner = inner_product/(numerical_data_centered.shape[0] - 1)
print("Sample Covariance Matrix using inner product: ")
pd.DataFrame(cov_matrix_inner)

for cov using outer prdocut, I've used below code:

outer_products = np.outer(numerical_data_centered, numerical_data_centered)

cov_matrix_outer = outer_products/(numerical_data_centered.shape[0] - 1)

print('Sample covariance matrix using outer product: ')
pd.DataFrame(cov_matrix_outer)
  1. What is the logical difference between covariance using inner and outer product ?
  2. Is the code written correct ?
  3. for a data with 3445 shape, inner cov has a shape of 2525 whereas outer cov has a shape of 344*344, is it correct or am i going somewhere wrong ?

Upvotes: 0

Views: 86

Answers (0)

Related Questions