Return Pearson product-moment correlation coefficients. Except for the handling of missing data this function does the same as `numpy.corrcoef`. For more details and examples, see `numpy.corrcoef`. Parameters ---------- x : array_like A 1-D or 2-D array containing
(x, y=None, rowvar=True, bias=np._NoValue, allow_masked=True,
ddof=np._NoValue)
| 1515 | |
| 1516 | |
| 1517 | def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, allow_masked=True, |
| 1518 | ddof=np._NoValue): |
| 1519 | """ |
| 1520 | Return Pearson product-moment correlation coefficients. |
| 1521 | |
| 1522 | Except for the handling of missing data this function does the same as |
| 1523 | `numpy.corrcoef`. For more details and examples, see `numpy.corrcoef`. |
| 1524 | |
| 1525 | Parameters |
| 1526 | ---------- |
| 1527 | x : array_like |
| 1528 | A 1-D or 2-D array containing multiple variables and observations. |
| 1529 | Each row of `x` represents a variable, and each column a single |
| 1530 | observation of all those variables. Also see `rowvar` below. |
| 1531 | y : array_like, optional |
| 1532 | An additional set of variables and observations. `y` has the same |
| 1533 | shape as `x`. |
| 1534 | rowvar : bool, optional |
| 1535 | If `rowvar` is True (default), then each row represents a |
| 1536 | variable, with observations in the columns. Otherwise, the relationship |
| 1537 | is transposed: each column represents a variable, while the rows |
| 1538 | contain observations. |
| 1539 | bias : _NoValue, optional |
| 1540 | Has no effect, do not use. |
| 1541 | |
| 1542 | .. deprecated:: 1.10.0 |
| 1543 | allow_masked : bool, optional |
| 1544 | If True, masked values are propagated pair-wise: if a value is masked |
| 1545 | in `x`, the corresponding value is masked in `y`. |
| 1546 | If False, raises an exception. Because `bias` is deprecated, this |
| 1547 | argument needs to be treated as keyword only to avoid a warning. |
| 1548 | ddof : _NoValue, optional |
| 1549 | Has no effect, do not use. |
| 1550 | |
| 1551 | .. deprecated:: 1.10.0 |
| 1552 | |
| 1553 | See Also |
| 1554 | -------- |
| 1555 | numpy.corrcoef : Equivalent function in top-level NumPy module. |
| 1556 | cov : Estimate the covariance matrix. |
| 1557 | |
| 1558 | Notes |
| 1559 | ----- |
| 1560 | This function accepts but discards arguments `bias` and `ddof`. This is |
| 1561 | for backwards compatibility with previous versions of this function. These |
| 1562 | arguments had no effect on the return values of the function and can be |
| 1563 | safely ignored in this and previous versions of numpy. |
| 1564 | """ |
| 1565 | msg = 'bias and ddof have no effect and are deprecated' |
| 1566 | if bias is not np._NoValue or ddof is not np._NoValue: |
| 1567 | # 2015-03-15, 1.10 |
| 1568 | warnings.warn(msg, DeprecationWarning, stacklevel=2) |
| 1569 | # Get the data |
| 1570 | (x, xnotmask, rowvar) = _covhelper(x, y, rowvar, allow_masked) |
| 1571 | # Compute the covariance matrix |
| 1572 | if not rowvar: |
| 1573 | fact = np.dot(xnotmask.T, xnotmask) * 1. |
| 1574 | c = (dot(x.T, x.conj(), strict=False) / fact).squeeze() |