MCPcopy Create free account
hub / github.com/numpy/numpy / corrcoef

Function corrcoef

numpy/lib/function_base.py:2758–2907  ·  view source on GitHub ↗

Return Pearson product-moment correlation coefficients. Please refer to the documentation for `cov` for more detail. The relationship between the correlation coefficient matrix, `R`, and the covariance matrix, `C`, is .. math:: R_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} C_{jj

(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *,
             dtype=None)

Source from the content-addressed store, hash-verified

2756
2757@array_function_dispatch(_corrcoef_dispatcher)
2758def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *,
2759 dtype=None):
2760 """
2761 Return Pearson product-moment correlation coefficients.
2762
2763 Please refer to the documentation for `cov` for more detail. The
2764 relationship between the correlation coefficient matrix, `R`, and the
2765 covariance matrix, `C`, is
2766
2767 .. math:: R_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} C_{jj} } }
2768
2769 The values of `R` are between -1 and 1, inclusive.
2770
2771 Parameters
2772 ----------
2773 x : array_like
2774 A 1-D or 2-D array containing multiple variables and observations.
2775 Each row of `x` represents a variable, and each column a single
2776 observation of all those variables. Also see `rowvar` below.
2777 y : array_like, optional
2778 An additional set of variables and observations. `y` has the same
2779 shape as `x`.
2780 rowvar : bool, optional
2781 If `rowvar` is True (default), then each row represents a
2782 variable, with observations in the columns. Otherwise, the relationship
2783 is transposed: each column represents a variable, while the rows
2784 contain observations.
2785 bias : _NoValue, optional
2786 Has no effect, do not use.
2787
2788 .. deprecated:: 1.10.0
2789 ddof : _NoValue, optional
2790 Has no effect, do not use.
2791
2792 .. deprecated:: 1.10.0
2793 dtype : data-type, optional
2794 Data-type of the result. By default, the return data-type will have
2795 at least `numpy.float64` precision.
2796
2797 .. versionadded:: 1.20
2798
2799 Returns
2800 -------
2801 R : ndarray
2802 The correlation coefficient matrix of the variables.
2803
2804 See Also
2805 --------
2806 cov : Covariance matrix
2807
2808 Notes
2809 -----
2810 Due to floating point rounding the resulting array may not be Hermitian,
2811 the diagonal elements may not be 1, and the elements may not satisfy the
2812 inequality abs(a) <= 1. The real and imaginary parts are clipped to the
2813 interval [-1, 1] in an attempt to improve on that situation but is not
2814 much help in the complex case.
2815

Callers 7

test_simpleMethod · 0.90
test_ddofMethod · 0.90
test_biasMethod · 0.90
test_complexMethod · 0.90
test_emptyMethod · 0.90
test_extremeMethod · 0.90
test_corrcoef_dtypeMethod · 0.90

Calls 5

diagFunction · 0.90
warnMethod · 0.80
clipMethod · 0.80
covFunction · 0.70
sqrtFunction · 0.70

Tested by 7

test_simpleMethod · 0.72
test_ddofMethod · 0.72
test_biasMethod · 0.72
test_complexMethod · 0.72
test_emptyMethod · 0.72
test_extremeMethod · 0.72
test_corrcoef_dtypeMethod · 0.72