pyssaBSS.utils
Functions
|
Computes the local covariance using a ball kernel. |
Computes the local covariance using a ring kernel. |
|
Generate a random invertible matrix of size p x p |
|
Generate a random orthogonal matrix of size n x n |
|
|
Computes the local covariance using a ring kernel. |
|
Sample autocovariance matrix at a given lag. |
|
Compute the covariance of the data points. |
|
Compute the mean of the data points. |
|
Computes the scaled local covariance using a ball kernel. |
|
Standardize the data. |
- pyssaBSS.utils.ball_kernel_local_sample_covariance(data, coords, radius, segment=None, seg_mean=None)[source]
Computes the local covariance using a ball kernel.
- Parameters:
data (ndarray of shape (p, n))
coords (ndarray of shape (n, 2))
radius (float) – radius of the ball kernel
segment (ndarray, optional) – indicates a subset of indices over which the local covariance is computed
seg_mean (ndarray of shape (p, 1), optional) – A precomputed mean of the segment. If None, it is computed
- Returns:
l_cov – local (spatial) covariance matrix
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.gaussian_kernel_local_sample_covariance(data, coords, radius, segment=None, seg_mean=None)[source]
Computes the local covariance using a ring kernel.
- Parameters:
data (ndarray of shape (p, n))
coords (ndarray of shape (n, 2))
radius (float) – radius of the gaussian kernel
segment (ndarray, optional) – indicates a subset of indices over which the local covariance is computed
seg_mean (ndarray of shape (p, 1), optional) – A precomputed mean of the segment. If None, it is computed
- Returns:
l_cov – local (spatial) covariance matrix
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.generate_random_invertible_matrix(p)[source]
Generate a random invertible matrix of size p x p
- Parameters:
p (int) – Number of rows and columns
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.generate_random_orthogonal_matrix(n)[source]
Generate a random orthogonal matrix of size n x n
- Parameters:
n (int) – Number of rows and columns
- Return type:
ndarray of shape (n, n)
- pyssaBSS.utils.ring_kernel_local_sample_covariance(data, coords, inner_radius, outer_radius, segment=None, seg_mean=None)[source]
Computes the local covariance using a ring kernel.
- Parameters:
data (ndarray of shape (p, n))
coords (ndarray of shape (n, 2))
inner_radius (float) – inner radius of the ring kernel
outer_radius (float) – outer radius of the ring kernel
segment (ndarray, optional) – indicates a subset of indices over which the local covariance is computed
seg_mean (ndarray of shape (p, 1), optional) – A precomputed mean of the segment. If None, it is computed
- Returns:
l_cov – local (spatial) covariance matrix
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.sample_autocovariance(data, lag, segment=None, seg_mean=None)[source]
Sample autocovariance matrix at a given lag.
- Parameters:
data (ndarray of shape (p, n))
lag (int) – Lag at which to compute autocovariance. Must be >= 0.
segment (ndarray of int indices, optional)
seg_mean (ndarray of shape (p,) or (p, 1), optional) – If None, computed from the segment.
- Returns:
acov – Not necessarily symmetric (acov(lag) != acov(lag).T for lag > 0).
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.sample_covariance(data, segment=None, seg_mean=None)[source]
Compute the covariance of the data points.
- Parameters:
data (ndarray of shape (p, n))
segment (ndarray, optional) – if provided, compute the covariance over the given indices
seg_mean (ndarray, optional) – if provided, the mean is not recomputed
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.sample_mean(data, segment=None)[source]
Compute the mean of the data points.
- Parameters:
data (ndarray of shape (p, n)) – if provided, compute the covariance over the given indi
segment (ndarray, optional)
- Return type:
ndarray of shape (p,)
- pyssaBSS.utils.scaled_local_sample_covariance(data, coords, radius, segment=None, seg_mean=None)[source]
Computes the scaled local covariance using a ball kernel.
- Parameters:
data (ndarray of shape (p, n))
coords (ndarray of shape (n, 2))
radius (float) – radius of the ball kernel
segment (ndarray, optional) – indicates a subset of indices over which the local covariance is computed
seg_mean (ndarray of shape (p, 1), optional) – A precomputed mean of the segment. If None, it is computed
- Returns:
l_cov – local (spatial) covariance matrix
- Return type:
ndarray of shape (p, p)
- pyssaBSS.utils.standardize_data(data)[source]
Standardize the data.
Afterwards, data has mean 0 and covariance I.
- Parameters:
data (ndarray of shape (p, n))
- Returns:
white_data (ndarray of shape (p, n)) – data after standardization
whitener (ndarray of shape (p, p)) – inverse square root of the covariance