0

# Pearson Correlation Matrix

Unsolved
###### Prob. and Stats

Difficulty: 2 | Problem written by Mr. Umair
A 2 x 2 Correlation Matrix is a matrix representing correlation coefficients between two variables. Pearson's Correlation Coefficient is the covariance of the two variables divided by the product of their standard deviations.

It can be shown as:

$$r = \frac{{}\sum_{i=1}^{n} (x_i - \overline{x})(y_i - \overline{y})} {\sqrt{\sum_{i=1}^{n} (x_i - \overline{x})^2(y_i - \overline{y})^2}}$$

Input:

Two NumPy arrays having same length.

Output:

Return the correlation matrix, which is a two-dimensional array with the correlation coefficients.

##### Sample Input:
<class 'numpy.ndarray'>
arr1: [1 0]
<class 'numpy.ndarray'>
arr2: [0 1]

##### Expected Output:
<class 'numpy.ndarray'>
[[ 1. -1.] [-1. 1.]]

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Have an issue, the MLPro support team is available 24X7 to Premium users.