spearmanr#
- mvpy.math.spearmanr(x: ndarray | Tensor, y: ndarray | Tensor, *args: Any) ndarray | Tensor[source]#
Compute Spearman correlation between x and y. Note that correlations are always computed over the final dimension in your inputs.
- Parameters:
- xUnion[np.ndarray, torch.Tensor]
Matrix to compute correlation with.
- yUnion[np.ndarray, torch.Tensor]
Matrix to compute correlation with.
- Returns:
- Union[np.ndarray, torch.Tensor]
Spearman correlations.
See also
Notes
Spearman correlations are defined as Pearson correlations between the ranks of x and y.
Examples
>>> import torch >>> from mvpy.math import spearmanr >>> x = torch.tensor([1, 5, 9]) >>> y = torch.tensor([1, 50, 60]) >>> spearmanr(x, y) tensor(1., dtype=torch.float64)