# .corrcoef()

Anonymous contributor
Anonymous contributor
Published Jul 24, 2024
Contribute to Docs

In NumPy, the `.corrcoef()` method computes the Pearson correlation coefficient of two specified arrays and returns an array as the result.

## Syntax

``````numpy.corrcoef(x, y=None, rowvar=True, dtype=None)
``````
• `x`: The first array to be used for computing the Pearson correlation coefficient.
• `y` (Optional): The second array to be used for computing the Pearson correlation coefficient.
• `rowvar` (Optional): If `True` (default), then each row represents a variable and each column contains an observation. If `False`, then the roles are reversed.
• `dtype` (Optional): Specifies the return data type.

## Example

The following example demonstrates the usage of the `.corrcoef()` method:

```# Importing the NumPy libraryimport numpy as np
# Defining two arraysarr1 = np.array([6, 21, 37])arr2 = np.array([1, 25, 51])
# Using the .corrcoef() methodres = np.corrcoef(arr1, arr2)
# Printing the resultprint(res)
```

The above code produces the following output:

```[[1.         0.99999002] [0.99999002 1.        ]]
```

## Codebyte Example

Run the following codebyte example to understand the use of the `.corrcoef()` method:

`usVisit uscodeHide codeCodeOutputHide outputHide outputLoading...`