![]() |
VOOZH | about |
Given a two set of random variable, find Covariance. Covariance is a measure of how much two random variables vary together. It’s similar to variance, but where variance tells you how a single variable varies, covariance tells you how two variables vary together. Covariance can be calculated by using the formula
Where x' and y' are the means of two given sets.
Examples:
Input : arr1[] = {65.21, 64.75, 65.26, 65.76, 65.96}
arr2[] = {67.25, 66.39, 66.12, 65.70, 66.64}
Output : -0.0580511
Input : arr1[] = {5, 20, 40, 80, 100}
arr2[] = {10, 24, 33, 54, 10}
Output : 187.75
Output:
-0.0580511
Time Complexity: O(N)
Auxiliary Space: O(1)