From 26a7593c74196def31f1f83be0d80e3f1d3ab33b Mon Sep 17 00:00:00 2001 From: fjosw Date: Tue, 9 Nov 2021 10:29:06 +0000 Subject: [PATCH] Documentation updated --- docs/pyerrors/linalg.html | 5 +- docs/pyerrors/misc.html | 5 +- docs/pyerrors/mpm.html | 187 ++++++-------------------------------- docs/pyerrors/obs.html | 5 +- docs/search.js | 2 +- 5 files changed, 34 insertions(+), 170 deletions(-) diff --git a/docs/pyerrors/linalg.html b/docs/pyerrors/linalg.html index f2f9cbe4..a1880a7f 100644 --- a/docs/pyerrors/linalg.html +++ b/docs/pyerrors/linalg.html @@ -99,10 +99,7 @@
View Source -
#!/usr/bin/env python
-# coding: utf-8
-
-import numpy as np
+            
import numpy as np
 from autograd import jacobian
 import autograd.numpy as anp  # Thinly-wrapped numpy
 from .obs import derived_observable, CObs, Obs
diff --git a/docs/pyerrors/misc.html b/docs/pyerrors/misc.html
index 856cb4ac..2e089cf9 100644
--- a/docs/pyerrors/misc.html
+++ b/docs/pyerrors/misc.html
@@ -69,10 +69,7 @@
                 
                         
View Source -
#!/usr/bin/env python
-# coding: utf-8
-
-import numpy as np
+            
import numpy as np
 from .obs import Obs
 
 
diff --git a/docs/pyerrors/mpm.html b/docs/pyerrors/mpm.html
index bdbb53de..3b14a4e9 100644
--- a/docs/pyerrors/mpm.html
+++ b/docs/pyerrors/mpm.html
@@ -50,9 +50,6 @@
             
  • matrix_pencil_method
  • -
  • - matrix_pencil_method_old -
  • @@ -72,29 +69,29 @@
    View Source -
    #!/usr/bin/env python
    -# coding: utf-8
    -
    -import numpy as np
    +            
    import numpy as np
     import scipy.linalg
     from .obs import Obs
    -from .linalg import svd, eig, pinv
    +from .linalg import svd, eig
     
     
     def matrix_pencil_method(corrs, k=1, p=None, **kwargs):
    -    """ Matrix pencil method to extract k energy levels from data
    +    """Matrix pencil method to extract k energy levels from data
     
         Implementation of the matrix pencil method based on
         eq. (2.17) of Y. Hua, T. K. Sarkar, IEEE Trans. Acoust. 38, 814-824 (1990)
     
         Parameters
         ----------
    -    data -- can be a list of Obs for the analysis of a single correlator, or a list of lists
    -            of Obs if several correlators are to analyzed at once.
    -    k -- Number of states to extract (default 1).
    -    p -- matrix pencil parameter which filters noise. The optimal value is expected between
    -         len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is
    -         to len(data)/2 but could possibly suppress more noise (default len(data)//2).
    +    data : list
    +        can be a list of Obs for the analysis of a single correlator, or a list of lists
    +        of Obs if several correlators are to analyzed at once.
    +    k : int
    +        Number of states to extract (default 1).
    +    p : int
    +        matrix pencil parameter which filters noise. The optimal value is expected between
    +        len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is
    +        to len(data)/2 but could possibly suppress more noise (default len(data)//2).
         """
         if isinstance(corrs[0], Obs):
             data = [corrs]
    @@ -130,58 +127,6 @@
         # Return the sorted logarithms of the real eigenvalues as Obs
         energy_levels = np.log(np.abs(eig(z, **kwargs)))
         return sorted(energy_levels, key=lambda x: abs(x.value))
    -
    -
    -def matrix_pencil_method_old(data, p, noise_level=None, verbose=1, **kwargs):
    -    """ Older impleentation of the matrix pencil method with pencil p on given data to
    -        extract energy levels.
    -
    -    Parameters
    -    ----------
    -    data -- lists of Obs, where the nth entry is considered to be the correlation function
    -            at x0=n+offset.
    -    p -- matrix pencil parameter which corresponds to the number of energy levels to extract.
    -         higher values for p can help decreasing noise.
    -    noise_level -- If this argument is not None an additional prefiltering via singular
    -                   value decomposition is performed in which all singular values below 10^(-noise_level)
    -                   times the largest singular value are discarded. This increases the computation time.
    -    verbose -- if larger than zero details about the noise filtering are printed to stdout
    -               (default 1)
    -
    -    """
    -    n_data = len(data)
    -    if n_data <= p:
    -        raise Exception('The pencil p has to be smaller than the number of data samples.')
    -
    -    matrix = scipy.linalg.hankel(data[:n_data - p], data[n_data - p - 1:]) @ np.identity(p + 1)
    -
    -    if noise_level is not None:
    -        u, s, vh = svd(matrix)
    -
    -        s_values = np.vectorize(lambda x: x.value)(s)
    -        if verbose > 0:
    -            print('Singular values: ', s_values)
    -        digit = np.argwhere(s_values / s_values[0] < 10.0**(-noise_level))
    -        if digit.size == 0:
    -            digit = len(s_values)
    -        else:
    -            digit = int(digit[0])
    -        if verbose > 0:
    -            print('Consider only', digit, 'out of', len(s), 'singular values')
    -
    -        new_matrix = u[:, :digit] * s[:digit] @ vh[:digit, :]
    -        y1 = new_matrix[:, :-1]
    -        y2 = new_matrix[:, 1:]
    -    else:
    -        y1 = matrix[:, :-1]
    -        y2 = matrix[:, 1:]
    -
    -    # Moore–Penrose pseudoinverse
    -    pinv_y1 = pinv(y1)
    -
    -    e = eig((pinv_y1 @ y2), **kwargs)
    -    energy_levels = -np.log(np.abs(e))
    -    return sorted(energy_levels, key=lambda x: abs(x.value))
     
    @@ -198,19 +143,22 @@
    View Source
    def matrix_pencil_method(corrs, k=1, p=None, **kwargs):
    -    """ Matrix pencil method to extract k energy levels from data
    +    """Matrix pencil method to extract k energy levels from data
     
         Implementation of the matrix pencil method based on
         eq. (2.17) of Y. Hua, T. K. Sarkar, IEEE Trans. Acoust. 38, 814-824 (1990)
     
         Parameters
         ----------
    -    data -- can be a list of Obs for the analysis of a single correlator, or a list of lists
    -            of Obs if several correlators are to analyzed at once.
    -    k -- Number of states to extract (default 1).
    -    p -- matrix pencil parameter which filters noise. The optimal value is expected between
    -         len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is
    -         to len(data)/2 but could possibly suppress more noise (default len(data)//2).
    +    data : list
    +        can be a list of Obs for the analysis of a single correlator, or a list of lists
    +        of Obs if several correlators are to analyzed at once.
    +    k : int
    +        Number of states to extract (default 1).
    +    p : int
    +        matrix pencil parameter which filters noise. The optimal value is expected between
    +        len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is
    +        to len(data)/2 but could possibly suppress more noise (default len(data)//2).
         """
         if isinstance(corrs[0], Obs):
             data = [corrs]
    @@ -258,94 +206,19 @@ eq. (2.17) of Y. Hua, T. K. Sarkar, IEEE Trans. Acoust. 38, 814-824 (1990)

    Parameters
      -
    • data -- can be a list of Obs for the analysis of a single correlator, or a list of lists: of Obs if several correlators are to analyzed at once.
    • -
    • k -- Number of states to extract (default 1).
    • -
    • p -- matrix pencil parameter which filters noise. The optimal value is expected between: len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is +
    • data (list): +can be a list of Obs for the analysis of a single correlator, or a list of lists +of Obs if several correlators are to analyzed at once.
    • +
    • k (int): +Number of states to extract (default 1).
    • +
    • p (int): +matrix pencil parameter which filters noise. The optimal value is expected between +len(data)/3 and 2*len(data)/3. The computation is more expensive the closer p is to len(data)/2 but could possibly suppress more noise (default len(data)//2).
    - -
    -
    #   - - - def - matrix_pencil_method_old(data, p, noise_level=None, verbose=1, **kwargs): -
    - -
    - View Source -
    def matrix_pencil_method_old(data, p, noise_level=None, verbose=1, **kwargs):
    -    """ Older impleentation of the matrix pencil method with pencil p on given data to
    -        extract energy levels.
    -
    -    Parameters
    -    ----------
    -    data -- lists of Obs, where the nth entry is considered to be the correlation function
    -            at x0=n+offset.
    -    p -- matrix pencil parameter which corresponds to the number of energy levels to extract.
    -         higher values for p can help decreasing noise.
    -    noise_level -- If this argument is not None an additional prefiltering via singular
    -                   value decomposition is performed in which all singular values below 10^(-noise_level)
    -                   times the largest singular value are discarded. This increases the computation time.
    -    verbose -- if larger than zero details about the noise filtering are printed to stdout
    -               (default 1)
    -
    -    """
    -    n_data = len(data)
    -    if n_data <= p:
    -        raise Exception('The pencil p has to be smaller than the number of data samples.')
    -
    -    matrix = scipy.linalg.hankel(data[:n_data - p], data[n_data - p - 1:]) @ np.identity(p + 1)
    -
    -    if noise_level is not None:
    -        u, s, vh = svd(matrix)
    -
    -        s_values = np.vectorize(lambda x: x.value)(s)
    -        if verbose > 0:
    -            print('Singular values: ', s_values)
    -        digit = np.argwhere(s_values / s_values[0] < 10.0**(-noise_level))
    -        if digit.size == 0:
    -            digit = len(s_values)
    -        else:
    -            digit = int(digit[0])
    -        if verbose > 0:
    -            print('Consider only', digit, 'out of', len(s), 'singular values')
    -
    -        new_matrix = u[:, :digit] * s[:digit] @ vh[:digit, :]
    -        y1 = new_matrix[:, :-1]
    -        y2 = new_matrix[:, 1:]
    -    else:
    -        y1 = matrix[:, :-1]
    -        y2 = matrix[:, 1:]
    -
    -    # Moore–Penrose pseudoinverse
    -    pinv_y1 = pinv(y1)
    -
    -    e = eig((pinv_y1 @ y2), **kwargs)
    -    energy_levels = -np.log(np.abs(e))
    -    return sorted(energy_levels, key=lambda x: abs(x.value))
    -
    - -
    - -

    Older impleentation of the matrix pencil method with pencil p on given data to - extract energy levels.

    - -
    Parameters
    - -
      -
    • data -- lists of Obs, where the nth entry is considered to be the correlation function: at x0=n+offset.
    • -
    • p -- matrix pencil parameter which corresponds to the number of energy levels to extract.: higher values for p can help decreasing noise.
    • -
    • noise_level -- If this argument is not None an additional prefiltering via singular: value decomposition is performed in which all singular values below 10^(-noise_level) -times the largest singular value are discarded. This increases the computation time.
    • -
    • verbose -- if larger than zero details about the noise filtering are printed to stdout: (default 1)
    • -
    -
    - -