Q:

Write a NumPy program to compute the covariance matrix of two given arrays

0

Write a NumPy program to compute the covariance matrix of two given arrays.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([0, 1, 2])
y = np.array([2, 1, 0])
print("\nOriginal array1:")
print(x)
print("\nOriginal array1:")
print(y)
print("\nCovariance matrix of the said arrays:\n",np.cov(x, y))

Sample Output:

Original array1:
[0 1 2]

Original array1:
[2 1 0]

Covariance matrix of the said arrays:
 [[ 1. -1.]
 [-1.  1.]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now