geocat.comp.stats.pearson_r
geocat.comp.stats.pearson_r#
- geocat.comp.stats.pearson_r(a, b, dim=None, weights=None, skipna=False, keep_attrs=False, axis=None)#
This function wraps the function of the same name from xskillscore. The difference between the xskillscore version and this one is that the GeoCAT version allows for array-like inputs rather than only supporting xarray.DataArrays. The parameters work the same way as in the xskillscore version, with an added parameter axis (see below).
- Parameters
a (
xarray.DataArray
,xarray.Dataset
,numpy.ndarray
) – Arrays over which to apply the function.b (
xarray.DataArray
,xarray.Dataset
,numpy.ndarray
) – Arrays over which to apply the function.dim (
str
,list
, optional) – The dimension(s) to apply the correlation along. Note that this dimension will be reduced as a result. Defaults to None reducing all dimensions. Only used when a and b are of type xarray.DataArray or xarray.Dataset.weights (
xarray.DataArray
,numpy.ndarray
, optional) – Weights matching dimensions of dim to apply during the function.skipna (
bool
, optional) – If True, skip NaNs when computing function.keep_attrs (
bool
, optional) – If True, the attributes (attrs) will be copied from the first input to the new one. If False (default), the new object will be returned without attributes. Only used when a and b are of types xarray.Dataset or xarray.DataArray.axis (
int
) – The axis to apply the correlation along. Only used when a and b are of type np.ndarray or are array-like.
- Returns
r (
xarray.DataArray
,numpy.ndarray
) – Pearson’s correlation coefficient