hofa.cdf#

This module contains the implementation of different alpha (weighting) functions to be used as weights for different eigenspaces depending on their eigenvalues.

Functions#

relu(eigvals, epsilon)

The cumulative distribution function that performs the denoising operator.

cutoff(eigvals, epsilon)

Apply a cutoff operator to some eigenvalues, returning a boolean mask.

avg_cutoff(eigvals, epsilon)

Apply an average cutoff function to eigenvalues, scaling them by epsilon.

top_eig(eigvals, n)

Give a mask that selects the top eigenvalues.

u2_dual(eigvals, unused)

The \(U^2\) dual operator.

Module Contents#

hofa.cdf.relu(eigvals: numpy.ndarray, epsilon: float)#

The cumulative distribution function that performs the denoising operator.

This function computes \(\max(1-\tfrac{\varepsilon}{\max(\sqrt{x},\varepsilon/2)},0)\) for each eigenvalue \(x\) in eigvals where epsilon equals \(\varepsilon\).

Parameters:
  • eigvals (np.ndarray) – A 1-D array of eigenvalues to which the cumulative distribution function of the denoising operator with parameter epsilon is applied.

  • epsilon (float) – A small constant used to adjust the threshold behavior of the denoising operator.

Returns:

An array of the same shape as eigvals, with the weights that perform the same operation as the denoising operator with parameter epsilon.

Return type:

np.ndarray

hofa.cdf.cutoff(eigvals: numpy.ndarray, epsilon: float)#

Apply a cutoff operator to some eigenvalues, returning a boolean mask.

This function returns True for all eigenvalues that are greater than or equal to \(\varepsilon^2\), and False otherwise where epsilon\(=\varepsilon\). In other words, it applies the map \(=1_{x\ge \varepsilon^2}\) for every \(x\) in eigvals.

Parameters:
  • eigvals (np.ndarray) – A 1-D array of eigenvalues to apply the cutoff function to.

  • epsilon (float) – A threshold value. Eigenvalues greater than or equal to \(\varepsilon^2\) are kept.

Returns:

A boolean array of the same shape as eigvals, where True indicates that the eigenvalue passes the cutoff condition.

Return type:

np.ndarray

hofa.cdf.avg_cutoff(eigvals: numpy.ndarray, epsilon: float)#

Apply an average cutoff function to eigenvalues, scaling them by epsilon.

This function computes \(\min \Big( \tfrac{ \sqrt{\max ( \varepsilon^2, x )}}{\varepsilon} - 1, 1 \Big)\) for each eigenvalue \(x\) in eigvals.

Parameters:
  • eigvals (np.ndarray) – A 1-D array of eigenvalues to apply the average cutoff function to.

  • epsilon (float) – A scaling factor used in the cutoff function. Smaller values of epsilon yield a stronger cutoff.

Returns:

An array of the same shape as eigvals, with the average cutoff transformation applied element-wise.

Return type:

np.ndarray

hofa.cdf.top_eig(eigvals: numpy.ndarray, n: int)#

Give a mask that selects the top eigenvalues.

This function returns a 1-D vector with the same shape as eigvals, consisting of all zeroes except in the positions of the largest n terms, which are ones.

Parameters:
  • eigvals (np.ndarray) – A 1-D array of eigenvalues to apply the mask function to.

  • n (int) – The number of eigenvalues to select.

Returns:

An array of the same shape as eigvals, containing zeros except at the first n positions, which are ones.

Return type:

np.ndarray

hofa.cdf.u2_dual(eigvals: numpy.ndarray, unused: float)#

The \(U^2\) dual operator.

This function returns a copy of eigvals.

Parameters:
  • eigvals (np.ndarray) – A 1-D array of eigenvalues.

  • unused (float) – Not used.

Returns:

A copy of eigvals.

Return type:

np.ndarray