8. Write a Python Numpy program to calculate cross-correlation of the two given array in the following output.
The output is:
Expected Answer:
Initial array1:
[1 2 3 4]
Initial array2:
[6 7 8 9]
Cross-correlation of the arrays:
[[1.66666667 1.66666667]
[1.66666667 1.66666667]]
Sample Answer:
import numpy as np
a = np.arange(1, 5)
b = np.arange(6, 10)
print("Initial array1:")
print(a)
print("\nInitial array2:")
print(b)
print("\nCross-correlation of the arrays:\n",np.cov(a, b))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)