pyssaBSS.utils

Functions

ball_kernel_local_sample_covariance(data, ...)

Computes the local covariance using a ball kernel.

gaussian_kernel_local_sample_covariance(...)

Computes the local covariance using a ring kernel.

generate_random_invertible_matrix(p)

Generate a random invertible matrix of size p x p

generate_random_orthogonal_matrix(n)

Generate a random orthogonal matrix of size n x n

ring_kernel_local_sample_covariance(data, ...)

Computes the local covariance using a ring kernel.

sample_autocovariance(data, lag[, segment, ...])

Sample autocovariance matrix at a given lag.

sample_covariance(data[, segment, seg_mean])

Compute the covariance of the data points.

sample_mean(data[, segment])

Compute the mean of the data points.

scaled_local_sample_covariance(data, coords, ...)

Computes the scaled local covariance using a ball kernel.

standardize_data(data)

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