netneurotools.stats.weighted_pearsonr
- netneurotools.stats.weighted_pearsonr(x_vec, y_vec, weight_vec, use_numba=False)[source]
Calculate weighted Pearson correlation coefficient.
- Parameters:
x_vec (array_like) – First vector of data
y_vec (array_like) – Second vector of data
weight_vec (array_like) – Vector of weights
use_numba (bool, optional) – Whether to use numba for calculation. Default: True (if numba is available).
- Returns:
corr – Weighted Pearson correlation coefficient
- Return type:
Notes
This function calculates the weighted Pearson correlation coefficient between two vectors, defined as:
\[r = \frac{\sum_i w_i (x_i - \bar{x})(y_i - \bar{y})} {\sqrt{\sum_i w_i (x_i - \bar{x})^2 \sum_i w_i (y_i - \bar{y})^2}}\]where \(x_i\) and \(y_i\) are the data points, \(w_i\) are the weights, and \(\bar{x}\) and \(\bar{y}\) are the weighted means of the data points.