diff --git a/docs/pyerrors.html b/docs/pyerrors.html index 7b75d7bc..a520da02 100644 --- a/docs/pyerrors.html +++ b/docs/pyerrors.html @@ -3,7 +3,7 @@
- +pyerrors
is a python package for error computation and propagation of Markov chain Monte Carlo data.\nIt is based on the gamma method arXiv:hep-lat/0306017. Some of its features are:
More detailed examples can found in the GitHub repository .
If you use pyerrors
for research that leads to a publication please consider citing:
and
\n\nwhere applicable.
\n\nThere exist similar publicly available implementations of gamma method error analysis suites in Fortran, Julia and Python.
\n\nInstall the most recent release using pip and pypi:
\n\npip install pyerrors # Fresh install\npip install -U pyerrors # Update\n
\nInstall the most recent release using conda and conda-forge:
\n\nconda install -c conda-forge pyerrors # Fresh install\nconda update -c conda-forge pyerrors # Update\n
\nInstall the current develop
version:
pip install git+https://github.com/fjosw/pyerrors.git@develop\n
\nimport numpy as np\nimport pyerrors as pe\n\nmy_obs = pe.Obs([samples], ['ensemble_name']) # Initialize an Obs object\nmy_new_obs = 2 * np.log(my_obs) / my_obs ** 2 # Construct derived Obs object\nmy_new_obs.gamma_method() # Estimate the statistical error\nprint(my_new_obs) # Print the result to stdout\n> 0.31498(72)\n
\nObs
classpyerrors
introduces a new datatype, Obs
, which simplifies error propagation and estimation for auto- and cross-correlated data.\nAn Obs
object can be initialized with two arguments, the first is a list containing the samples for an observable from a Monte Carlo chain.\nThe samples can either be provided as python list or as numpy array.\nThe second argument is a list containing the names of the respective Monte Carlo chains as strings. These strings uniquely identify a Monte Carlo chain/ensemble. It is crucial for the correct error propagation that observations from the same Monte Carlo history are labeled with the same name. See Multiple ensembles/replica for details.
import pyerrors as pe\n\nmy_obs = pe.Obs([samples], ['ensemble_name'])\n
\nWhen performing mathematical operations on Obs
objects the correct error propagation is intrinsically taken care of using a first order Taylor expansion\n$$\\delta_f^i=\\sum_\\alpha \\bar{f}_\\alpha \\delta_\\alpha^i\\,,\\quad \\delta_\\alpha^i=a_\\alpha^i-\\bar{a}_\\alpha\\,,$$\nas introduced in arXiv:hep-lat/0306017.\nThe required derivatives $\\bar{f}_\\alpha$ are evaluated up to machine precision via automatic differentiation as suggested in arXiv:1809.01289.
The Obs
class is designed such that mathematical numpy functions can be used on Obs
just as for regular floats.
import numpy as np\nimport pyerrors as pe\n\nmy_obs1 = pe.Obs([samples1], ['ensemble_name'])\nmy_obs2 = pe.Obs([samples2], ['ensemble_name'])\n\nmy_sum = my_obs1 + my_obs2\n\nmy_m_eff = np.log(my_obs1 / my_obs2)\n\niamzero = my_m_eff - my_m_eff\n# Check that value and fluctuations are zero within machine precision\nprint(iamzero == 0.0)\n> True\n
\nThe error estimation within pyerrors
is based on the gamma method introduced in arXiv:hep-lat/0306017.\nAfter having arrived at the derived quantity of interest the gamma_method
can be called as detailed in the following example.
my_sum.gamma_method()\nprint(my_sum)\n> 1.70(57)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 5.72046658e-01 +/- 7.56746598e-02 (33.650%)\n> t_int 2.71422900e+00 +/- 6.40320983e-01 S = 2.00\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nWe use the following definition of the integrated autocorrelation time established in Madras & Sokal 1988\n$$\\tau_\\mathrm{int}=\\frac{1}{2}+\\sum_{t=1}^{W}\\rho(t)\\geq \\frac{1}{2}\\,.$$\nThe window $W$ is determined via the automatic windowing procedure described in arXiv:hep-lat/0306017.\nThe standard value for the parameter $S$ of this automatic windowing procedure is $S=2$. Other values for $S$ can be passed to the gamma_method
as parameter.
my_sum.gamma_method(S=3.0)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 6.30675201e-01 +/- 1.04585650e-01 (37.099%)\n> t_int 3.29909703e+00 +/- 9.77310102e-01 S = 3.00\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nThe integrated autocorrelation time $\\tau_\\mathrm{int}$ and the autocorrelation function $\\rho(W)$ can be monitored via the methods pyerrors.obs.Obs.plot_tauint
and pyerrors.obs.Obs.plot_rho
.
If the parameter $S$ is set to zero it is assumed that the dataset does not exhibit any autocorrelation and the window size is chosen to be zero.\nIn this case the error estimate is identical to the sample standard error.
\n\nSlow modes in the Monte Carlo history can be accounted for by attaching an exponential tail to the autocorrelation function $\\rho$ as suggested in arXiv:1009.5228. The longest autocorrelation time in the history, $\\tau_\\mathrm{exp}$, can be passed to the gamma_method
as parameter. In this case the automatic windowing procedure is vacated and the parameter $S$ does not affect the error estimate.
my_sum.gamma_method(tau_exp=7.2)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 6.28097762e-01 +/- 5.79077524e-02 (36.947%)\n> t_int 3.27218667e+00 +/- 7.99583654e-01 tau_exp = 7.20, N_sigma = 1\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nFor the full API see pyerrors.obs.Obs.gamma_method
.
Error propagation for multiple ensembles (Markov chains with different simulation parameters) is handled automatically. Ensembles are uniquely identified by their name
.
obs1 = pe.Obs([samples1], ['ensemble1'])\nobs2 = pe.Obs([samples2], ['ensemble2'])\n\nmy_sum = obs1 + obs2\nmy_sum.details()\n> Result 2.00697958e+00\n> 1500 samples in 2 ensembles:\n> \u00b7 Ensemble 'ensemble1' : 1000 configurations (from 1 to 1000)\n> \u00b7 Ensemble 'ensemble2' : 500 configurations (from 1 to 500)\n
\nObservables from the same Monte Carlo chain have to be initialized with the same name for correct error propagation. If different names were used in this case the data would be treated as statistically independent resulting in loss of relevant information and a potential over or under estimate of the statistical error.
\n\npyerrors
identifies multiple replica (independent Markov chains with identical simulation parameters) by the vertical bar |
in the name of the data set.
obs1 = pe.Obs([samples1], ['ensemble1|r01'])\nobs2 = pe.Obs([samples2], ['ensemble1|r02'])\n\n> my_sum = obs1 + obs2\n> my_sum.details()\n> Result 2.00697958e+00\n> 1500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1'\n> \u00b7 Replicum 'r01' : 1000 configurations (from 1 to 1000)\n> \u00b7 Replicum 'r02' : 500 configurations (from 1 to 500)\n
\nIn order to keep track of different error analysis parameters for different ensembles one can make use of global dictionaries as detailed in the following example.
\n\npe.Obs.S_dict['ensemble1'] = 2.5\npe.Obs.tau_exp_dict['ensemble2'] = 8.0\npe.Obs.tau_exp_dict['ensemble3'] = 2.0\n
\nIn case the gamma_method
is called without any parameters it will use the values specified in the dictionaries for the respective ensembles.\nPassing arguments to the gamma_method
still dominates over the dictionaries.
Obs
objects defined on irregular Monte Carlo chains can be initialized with the parameter idl
.
# Observable defined on configurations 20 to 519\nobs1 = pe.Obs([samples1], ['ensemble1'], idl=[range(20, 520)])\nobs1.details()\n> Result 9.98319881e-01\n> 500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 500 configurations (from 20 to 519)\n\n# Observable defined on every second configuration between 5 and 1003\nobs2 = pe.Obs([samples2], ['ensemble1'], idl=[range(5, 1005, 2)])\nobs2.details()\n> Result 9.99100712e-01\n> 500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 500 configurations (from 5 to 1003 in steps of 2)\n\n# Observable defined on configurations 2, 9, 28, 29 and 501\nobs3 = pe.Obs([samples3], ['ensemble1'], idl=[[2, 9, 28, 29, 501]])\nobs3.details()\n> Result 1.01718064e+00\n> 5 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 5 configurations (irregular range)\n
\nObs
objects defined on regular and irregular histories of the same ensemble can be combined with each other and the correct error propagation and estimation is automatically taken care of.
Warning: Irregular Monte Carlo chains can result in odd patterns in the autocorrelation functions.\nMake sure to check the autocorrelation time with e.g. pyerrors.obs.Obs.plot_rho
or pyerrors.obs.Obs.plot_tauint
.
For the full API see pyerrors.obs.Obs
.
When one is not interested in single observables but correlation functions, pyerrors
offers the Corr
class which simplifies the corresponding error propagation and provides the user with a set of standard methods. In order to initialize a Corr
objects one needs to arrange the data as a list of Obs
my_corr = pe.Corr([obs_0, obs_1, obs_2, obs_3])\nprint(my_corr)\n> x0/a Corr(x0/a)\n> ------------------\n> 0 0.7957(80)\n> 1 0.5156(51)\n> 2 0.3227(33)\n> 3 0.2041(21)\n
\nIn case the correlation functions are not defined on the outermost timeslices, for example because of fixed boundary conditions, a padding can be introduced.
\n\nmy_corr = pe.Corr([obs_0, obs_1, obs_2, obs_3], padding=[1, 1])\nprint(my_corr)\n> x0/a Corr(x0/a)\n> ------------------\n> 0\n> 1 0.7957(80)\n> 2 0.5156(51)\n> 3 0.3227(33)\n> 4 0.2041(21)\n> 5\n
\nThe individual entries of a correlator can be accessed via slicing
\n\nprint(my_corr[3])\n> 0.3227(33)\n
\nError propagation with the Corr
class works very similar to Obs
objects. Mathematical operations are overloaded and Corr
objects can be computed together with other Corr
objects, Obs
objects or real numbers and integers.
my_new_corr = 0.3 * my_corr[2] * my_corr * my_corr + 12 / my_corr\n
\npyerrors
provides the user with a set of regularly used methods for the manipulation of correlator objects:
Corr.gamma_method
applies the gamma method to all entries of the correlator.Corr.m_eff
to construct effective masses. Various variants for periodic and fixed temporal boundary conditions are available.Corr.deriv
returns the first derivative of the correlator as Corr
. Different discretizations of the numerical derivative are available.Corr.second_deriv
returns the second derivative of the correlator as Corr
. Different discretizations of the numerical derivative are available.Corr.symmetric
symmetrizes parity even correlations functions, assuming periodic boundary conditions.Corr.anti_symmetric
anti-symmetrizes parity odd correlations functions, assuming periodic boundary conditions.Corr.T_symmetry
averages a correlator with its time symmetry partner, assuming fixed boundary conditions.Corr.plateau
extracts a plateau value from the correlator in a given range.Corr.roll
periodically shifts the correlator.Corr.reverse
reverses the time ordering of the correlator.Corr.correlate
constructs a disconnected correlation function from the correlator and another Corr
or Obs
object.Corr.reweight
reweights the correlator.pyerrors
can also handle matrices of correlation functions and extract energy states from these matrices via a generalized eigenvalue problem (see pyerrors.correlators.Corr.GEVP
).
For the full API see pyerrors.correlators.Corr
.
pyerrors
can handle complex valued observables via the class pyerrors.obs.CObs
.\nCObs
are initialized with a real and an imaginary part which both can be Obs
valued.
my_real_part = pe.Obs([samples1], ['ensemble1'])\nmy_imag_part = pe.Obs([samples2], ['ensemble1'])\n\nmy_cobs = pe.CObs(my_real_part, my_imag_part)\nmy_cobs.gamma_method()\nprint(my_cobs)\n> (0.9959(91)+0.659(28)j)\n
\nElementary mathematical operations are overloaded and samples are properly propagated as for the Obs
class.
my_derived_cobs = (my_cobs + my_cobs.conjugate()) / np.abs(my_cobs)\nmy_derived_cobs.gamma_method()\nprint(my_derived_cobs)\n> (1.668(23)+0.0j)\n
\nCovobs
classIn many projects, auxiliary data that is not based on Monte Carlo chains enters. Examples are experimentally determined mesons masses which are used to set the scale or renormalization constants. These numbers come with an error that has to be propagated through the analysis. The Covobs
class allows to define such quantities in pyerrors
. Furthermore, external input might consist of correlated quantities. An example are the parameters of an interpolation formula, which are defined via mean values and a covariance matrix between all parameters. The contribution of the interpolation formula to the error of a derived quantity therefore might depend on the complete covariance matrix.
This concept is built into the definition of Covobs
. In pyerrors
, external input is defined by $M$ mean values, a $M\\times M$ covariance matrix, where $M=1$ is permissible, and a name that uniquely identifies the covariance matrix. Below, we define the pion mass, based on its mean value and error, 134.9768(5). Note, that the square of the error enters cov_Obs
, since the second argument of this function is the covariance matrix of the Covobs
.
import pyerrors.obs as pe\n\nmpi = pe.cov_Obs(134.9768, 0.0005**2, 'pi^0 mass')\nmpi.gamma_method()\nmpi.details()\n> Result 1.34976800e+02 +/- 5.00000000e-04 +/- 0.00000000e+00 (0.000%)\n> pi^0 mass 5.00000000e-04\n> 0 samples in 1 ensemble:\n> \u00b7 Covobs 'pi^0 mass'\n
\nThe resulting object mpi
is an Obs
that contains a Covobs
. In the following, it may be handled as any other Obs
. The contribution of the covariance matrix to the error of an Obs
is determined from the $M \\times M$ covariance matrix $\\Sigma$ and the gradient of the Obs
with respect to the external quantities, which is the $1\\times M$ Jacobian matrix $J$, via\n$$s = \\sqrt{J^T \\Sigma J}\\,,$$\nwhere the Jacobian is computed for each derived quantity via automatic differentiation.
Correlated auxiliary data is defined similarly to above, e.g., via
\n\nRAP = pe.cov_Obs([16.7457, -19.0475], [[3.49591, -6.07560], [-6.07560, 10.5834]], 'R_AP, 1906.03445, (5.3a)')\nprint(RAP)\n> [Obs[16.7(1.9)], Obs[-19.0(3.3)]]\n
\nwhere RAP
now is a list of two Obs
that contains the two correlated parameters.
Since the gradient of a derived observable with respect to an external covariance matrix is propagated through the entire analysis, the Covobs
class allows to quote the derivative of a result with respect to the external quantities. If these derivatives are published together with the result, small shifts in the definition of external quantities, e.g., the definition of the physical point, can be performed a posteriori based on the published information. This may help to compare results of different groups. The gradient of an Obs
o
with respect to a covariance matrix with the identifying string k
may be accessed via
o.covobs[k].grad\n
\npyerrors
supports exact linear error propagation for iterative algorithms like various variants of non-linear least squares fits or root finding. The derivatives required for the error propagation are calculated as described in arXiv:1809.01289.
Standard non-linear least square fits with errors on the dependent but not the independent variables can be performed with pyerrors.fits.least_squares
. As default solver the Levenberg-Marquardt algorithm implemented in scipy is used.
Fit functions have to be of the following form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[1] * anp.exp(-a[0] * x)\n
\nIt is important that numerical functions refer to autograd.numpy
instead of numpy
for the automatic differentiation in iterative algorithms to work properly.
Fits can then be performed via
\n\nfit_result = pe.fits.least_squares(x, y, func)\nprint("\\n", fit_result)\n> Fit with 2 parameters\n> Method: Levenberg-Marquardt\n> `ftol` termination condition is satisfied.\n> chisquare/d.o.f.: 0.9593035785160936\n\n> Goodness of fit:\n> \u03c7\u00b2/d.o.f. = 0.959304\n> p-value = 0.5673\n> Fit parameters:\n> 0 0.0548(28)\n> 1 1.933(64)\n
\nwhere x is a list
or numpy.array
of floats
and y is a list
or numpy.array
of Obs
.
Data stored in Corr
objects can be fitted directly using the Corr.fit
method.
my_corr = pe.Corr(y)\nfit_result = my_corr.fit(func, fitrange=[12, 25])\n
\nthis can simplify working with absolute fit ranges and takes care of gaps in the data automatically.
\n\nFor fit functions with multiple independent variables the fit function can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\npyerrors
also supports correlated fits which can be triggered via the parameter correlated_fit=True
.\nDetails about how the required covariance matrix is estimated can be found in pyerrors.obs.covariance
.
Direct visualizations of the performed fits can be triggered via resplot=True
or qqplot=True
. For all available options see pyerrors.fits.least_squares
.
pyerrors
can also fit data with errors on both the dependent and independent variables using the total least squares method also referred to orthogonal distance regression as implemented in scipy, see pyerrors.fits.least_squares
. The syntax is identical to the standard least squares case, the only difference being that x
also has to be a list
or numpy.array
of Obs
.
For the full API see pyerrors.fits
for fits and pyerrors.roots
for finding roots of functions.
pyerrors
provides wrappers for Obs
- and CObs
-valued matrix operations based on numpy.linalg
. The supported functions include:
inv
for the matrix inverse.cholseky
for the Cholesky decomposition.det
for the matrix determinant.eigh
for eigenvalues and eigenvectors of hermitean matrices.eig
for eigenvalues of general matrices.pinv
for the Moore-Penrose pseudoinverse.svd
for the singular-value-decomposition.For the full API see pyerrors.linalg
.
The preferred exported file format within pyerrors
is json.gz. Files written to this format are valid JSON files that have been compressed using gzip. The structure of the content is inspired by the dobs format of the ALPHA collaboration. The aim of the format is to facilitate the storage of data in a self-contained way such that, even years after the creation of the file, it is possible to extract all necessary information:
This can be achieved by storing all information in one single file. The export routines of pyerrors
are written such that as much information as possible is written automatically as described in the following example
my_obs = pe.Obs([samples], ["test_ensemble"])\nmy_obs.tag = "My observable"\n\npe.input.json.dump_to_json(my_obs, "test_output_file", description="This file contains a test observable")\n# For a single observable one can equivalently use the class method dump\nmy_obs.dump("test_output_file", description="This file contains a test observable")\n\ncheck = pe.input.json.load_json("test_output_file")\n\nprint(my_obs == check)\n> True\n
\nThe format also allows to directly write out the content of Corr
objects or lists and arrays of Obs
objects by passing the desired data to pyerrors.input.json.dump_to_json
.
The first entries of the file provide optional auxiliary information:
\n\nprogram
is a string that indicates which program was used to write the file.version
is a string that specifies the version of the format.who
is a string that specifies the user name of the creator of the file.date
is a string and contains the creation date of the file.host
is a string and contains the hostname of the machine where the file has been written.description
contains information on the content of the file. This field is not filled automatically in pyerrors
. The user is advised to provide as detailed information as possible in this field. Examples are: Input files of measurements or simulations, LaTeX formulae or references to publications to specify how the observables have been computed, details on the analysis strategy, ... This field may be any valid JSON type. Strings, arrays or objects (equivalent to dicts in python) are well suited to provide information.The only necessary entry of the file is the field\n-obsdata
, an array that contains the actual data.
Each entry of the array belongs to a single structure of observables. Currently, these structures can be either of Obs
, list
, numpy.ndarray
, Corr
. All Obs
inside a structure (with dimension > 0) have to be defined on the same set of configurations. Different structures, that are represented by entries of the array obsdata
, are treated independently. Each entry of the array obsdata
has the following required entries:
type
is a string that specifies the type of the structure. This allows to parse the content to the correct form after reading the file. It is always possible to interpret the content as list of Obs.value
is an array that contains the mean values of the Obs inside the structure.\nThe following entries are optional:layout
is a string that specifies the layout of multi-dimensional structures. Examples are \"2, 2\" for a 2x2 dimensional matrix or \"64, 4, 4\" for a Corr with $T=64$ and 4x4 matrices on each time slices. \"1\" denotes a single Obs. Multi-dimensional structures are stored in row-major format (see below).tag
is any JSON type. It contains additional information concerning the structure. The tag
of an Obs
in pyerrors
is written here.reweighted
is a Bool that may be used to specify, whether the Obs
in the structure have been reweighted.data
is an array that contains the data from MC chains. We will define it below.cdata
is an array that contains the data from external quantities with an error (Covobs
in pyerrors
). We will define it below.The array data
contains the data from MC chains. Each entry of the array corresponds to one ensemble and contains:
id
, a string that contains the name of the ensemblereplica
, an array that contains an entry per replica of the ensemble.Each entry of replica
contains\nname
, a string that contains the name of the replica\ndeltas
, an array that contains the actual data.
Each entry in deltas
corresponds to one configuration of the replica and has $1+N$ many entries. The first entry is an integer that specifies the configuration number that, together with ensemble and replica name, may be used to uniquely identify the configuration on which the data has been obtained. The following N entries specify the deltas, i.e., the deviation of the observable from the mean value on this configuration, of each Obs
inside the structure. Multi-dimensional structures are stored in a row-major format. For primary observables, such as correlation functions, $value + delta_i$ matches the primary data obtained on the configuration.
The array cdata
contains information about the contribution of auxiliary observables, represented by Covobs
in pyerrors
, to the total error of the observables. Each entry of the array belongs to one auxiliary covariance matrix and contains:
id
, a string that identifies the covariance matrixlayout
, a string that defines the dimensions of the $M\\times M$ covariance matrix (has to be \"M, M\" or \"1\").cov
, an array that contains the $M\\times M$ many entries of the covariance matrix, stored in row-major format.grad
, an array that contains N entries, one for each Obs
inside the structure. Each entry itself is an array, that contains the M gradients of the Nth observable with respect to the quantity that corresponds to the Mth diagonal entry of the covariance matrix.A JSON schema that may be used to verify the correctness of a file with respect to the format definition is stored in ./examples/json_schema.json. The schema is a self-descriptive format definition and contains an exemplary file.
\n\nJulia I/O routines for the json.gz format, compatible with ADerrors.jl, can be found here.
\n"}, "pyerrors.correlators": {"fullname": "pyerrors.correlators", "modulename": "pyerrors.correlators", "kind": "module", "doc": "\n"}, "pyerrors.correlators.Corr": {"fullname": "pyerrors.correlators.Corr", "modulename": "pyerrors.correlators", "qualname": "Corr", "kind": "class", "doc": "The class for a correlator (time dependent sequence of pe.Obs).
\n\nEverything, this class does, can be achieved using lists or arrays of Obs.\nBut it is simply more convenient to have a dedicated object for correlators.\nOne often wants to add or multiply correlators of the same length at every timeslice and it is inconvenient\nto iterate over all timeslices for every operation. This is especially true, when dealing with matrices.
\n\nThe correlator can have two types of content: An Obs at every timeslice OR a GEVP\nmatrix at every timeslice. Other dependency (eg. spatial) are not supported.
\n"}, "pyerrors.correlators.Corr.__init__": {"fullname": "pyerrors.correlators.Corr.__init__", "modulename": "pyerrors.correlators", "qualname": "Corr.__init__", "kind": "function", "doc": "Initialize a Corr object.
\n\nApply the gamma method to the content of the Corr.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.correlators.Corr.gm": {"fullname": "pyerrors.correlators.Corr.gm", "modulename": "pyerrors.correlators", "qualname": "Corr.gm", "kind": "function", "doc": "Apply the gamma method to the content of the Corr.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.correlators.Corr.projected": {"fullname": "pyerrors.correlators.Corr.projected", "modulename": "pyerrors.correlators", "qualname": "Corr.projected", "kind": "function", "doc": "We need to project the Correlator with a Vector to get a single value at each timeslice.
\n\nThe method can use one or two vectors.\nIf two are specified it returns v1@G@v2 (the order might be very important.)\nBy default it will return the lowest source, which usually means unsmeared-unsmeared (0,0), but it does not have to
\n", "signature": "(self, vector_l=None, vector_r=None, normalize=False):", "funcdef": "def"}, "pyerrors.correlators.Corr.item": {"fullname": "pyerrors.correlators.Corr.item", "modulename": "pyerrors.correlators", "qualname": "Corr.item", "kind": "function", "doc": "Picks the element [i,j] from every matrix and returns a correlator containing one Obs per timeslice.
\n\nOutputs the correlator in a plotable format.
\n\nOutputs three lists containing the timeslice index, the value on each\ntimeslice and the error on each timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.symmetric": {"fullname": "pyerrors.correlators.Corr.symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.symmetric", "kind": "function", "doc": "Symmetrize the correlator around x0=0.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.anti_symmetric": {"fullname": "pyerrors.correlators.Corr.anti_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.anti_symmetric", "kind": "function", "doc": "Anti-symmetrize the correlator around x0=0.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.is_matrix_symmetric": {"fullname": "pyerrors.correlators.Corr.is_matrix_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.is_matrix_symmetric", "kind": "function", "doc": "Checks whether a correlator matrices is symmetric on every timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.matrix_symmetric": {"fullname": "pyerrors.correlators.Corr.matrix_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.matrix_symmetric", "kind": "function", "doc": "Symmetrizes the correlator matrices on every timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.GEVP": {"fullname": "pyerrors.correlators.Corr.GEVP", "modulename": "pyerrors.correlators", "qualname": "Corr.GEVP", "kind": "function", "doc": "Solve the generalized eigenvalue problem on the correlator matrix and returns the corresponding eigenvectors.
\n\nThe eigenvectors are sorted according to the descending eigenvalues, the zeroth eigenvector(s) correspond to the\nlargest eigenvalue(s). The eigenvector(s) for the individual states can be accessed via slicing
\n\nC.GEVP(t0=2)[0] # Ground state vector(s)\nC.GEVP(t0=2)[:3] # Vectors for the lowest three states\n
\nDetermines the eigenvalue of the GEVP by solving and projecting the correlator
\n\nConstructs an NxN Hankel matrix
\n\nC(t) c(t+1) ... c(t+n-1)\nC(t+1) c(t+2) ... c(t+n)\n.................\nC(t+(n-1)) c(t+n) ... c(t+2(n-1))
\n\nPeriodically shift the correlator by dt timeslices
\n\nReverse the time ordering of the Corr
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.thin": {"fullname": "pyerrors.correlators.Corr.thin", "modulename": "pyerrors.correlators", "qualname": "Corr.thin", "kind": "function", "doc": "Thin out a correlator to suppress correlations
\n\nCorrelate the correlator with another correlator or Obs
\n\nReweight the correlator.
\n\nReturn the time symmetry average of the correlator and its partner
\n\nReturn the first derivative of the correlator with respect to x0.
\n\nReturn the second derivative of the correlator with respect to x0.
\n\nReturns the effective mass of the correlator as correlator object
\n\nFits function to the data
\n\nfitrange=[4, 6]
corresponds to the three entries 4, 5 and 6.\nIf not specified, self.prange or all timeslices are used.Extract a plateau value from a Corr object
\n\nSets the attribute prange of the Corr object.
\n", "signature": "(self, prange):", "funcdef": "def"}, "pyerrors.correlators.Corr.show": {"fullname": "pyerrors.correlators.Corr.show", "modulename": "pyerrors.correlators", "qualname": "Corr.show", "kind": "function", "doc": "Plots the correlator using the tag of the correlator as label if available.
\n\nProduces a spaghetti plot of the correlator suited to monitor exceptional configurations.
\n\nDumps the Corr into a file of chosen type
\n\nProject large correlation matrix to lowest states
\n\nThis method can be used to reduce the size of an (N x N) correlation matrix\nto (Ntrunc x Ntrunc) by solving a GEVP at very early times where the noise\nis still small.
\n\nWe have the basematrix $C(t)$ and the target matrix $G(t)$. We start by solving\nthe GEVP $$C(t) v_n(t, t_0) = \\lambda_n(t, t_0) C(t_0) v_n(t, t_0)$$ where $t \\equiv t_\\mathrm{proj}$\nand $t_0 \\equiv t_{0, \\mathrm{proj}}$. The target matrix is projected onto the subspace of the\nresulting eigenvectors $v_n, n=1,\\dots,N_\\mathrm{trunc}$ via\n$$G^\\prime_{i, j}(t) = (v_i, G(t) v_j)$$. This allows to reduce the size of a large\ncorrelation matrix and to remove some noise that is added by irrelevant operators.\nThis may allow to use the GEVP on $G(t)$ at late times such that the theoretically motivated\nbound $t_0 \\leq t/2$ holds, since the condition number of $G(t)$ is decreased, compared to $C(t)$.
\n", "signature": "(self, Ntrunc, tproj=3, t0proj=2, basematrix=None):", "funcdef": "def"}, "pyerrors.covobs": {"fullname": "pyerrors.covobs", "modulename": "pyerrors.covobs", "kind": "module", "doc": "\n"}, "pyerrors.covobs.Covobs": {"fullname": "pyerrors.covobs.Covobs", "modulename": "pyerrors.covobs", "qualname": "Covobs", "kind": "class", "doc": "\n"}, "pyerrors.covobs.Covobs.__init__": {"fullname": "pyerrors.covobs.Covobs.__init__", "modulename": "pyerrors.covobs", "qualname": "Covobs.__init__", "kind": "function", "doc": "Initialize Covobs object.
\n\nReturn the variance (= square of the error) of the Covobs
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.dirac": {"fullname": "pyerrors.dirac", "modulename": "pyerrors.dirac", "kind": "module", "doc": "\n"}, "pyerrors.dirac.epsilon_tensor": {"fullname": "pyerrors.dirac.epsilon_tensor", "modulename": "pyerrors.dirac", "qualname": "epsilon_tensor", "kind": "function", "doc": "Rank-3 epsilon tensor
\n\nBased on https://codegolf.stackexchange.com/a/160375
\n\nRank-4 epsilon tensor
\n\nExtension of https://codegolf.stackexchange.com/a/160375
\n\nReturns gamma matrix in Grid labeling.
\n", "signature": "(gamma_tag):", "funcdef": "def"}, "pyerrors.fits": {"fullname": "pyerrors.fits", "modulename": "pyerrors.fits", "kind": "module", "doc": "\n"}, "pyerrors.fits.Fit_result": {"fullname": "pyerrors.fits.Fit_result", "modulename": "pyerrors.fits", "qualname": "Fit_result", "kind": "class", "doc": "Represents fit results.
\n\nApply the gamma method to all fit parameters
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.fits.Fit_result.gm": {"fullname": "pyerrors.fits.Fit_result.gm", "modulename": "pyerrors.fits", "qualname": "Fit_result.gm", "kind": "function", "doc": "Apply the gamma method to all fit parameters
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.fits.least_squares": {"fullname": "pyerrors.fits.least_squares", "modulename": "pyerrors.fits", "qualname": "least_squares", "kind": "function", "doc": "Performs a non-linear fit to y = func(x).\n ```
\n\nfunc (object):\nfit function, has to be of the form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[0] + a[1] * x + a[2] * anp.sinh(x)\n
\nFor multiple x values func can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
funcs (dict):\ndict of objects\nfit functions have to be of the form (here a[0] is the common fit parameter)\n```python\nimport autograd.numpy as anp\nfuncs = {\"a\": func_a,\n \"b\": func_b}
\n\ndef func_a(a, x):\n return a[1] * anp.exp(-a[0] * x)
\n\ndef func_b(a, x):\n return a[2] * anp.exp(-a[0] * x)
\n\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
pyerrors.obs.covariance
.\nIn practice the correlation matrix is Cholesky decomposed and inverted (instead of the covariance matrix).\nThis procedure should be numerically more stable as the correlation matrix is typically better conditioned (Jacobi preconditioning).Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.
\n\nfunc (object):\nfunc has to be of the form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[0] + a[1] * x + a[2] * anp.sinh(x)\n
\nFor multiple x values func can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
Based on the orthogonal distance regression module of scipy.
\n\nPerforms a linear fit to y = n + m * x and returns two Obs n, m.
\n\nGenerates a quantile-quantile plot of the fit result which can be used to\n check if the residuals of the fit are gaussian distributed.
\n\nGenerates a plot which compares the fit to the data and displays the corresponding residuals
\n\nFor uncorrelated data the residuals are expected to be distributed ~N(0,1).
\n\nCalculate the error band for an array of sample values x, for given fit function func with optimized parameters beta.
\n\nPerforms a Kolmogorov\u2013Smirnov test for the p-values of all fit object.
\n\npyerrors
includes an input
submodule in which input routines and parsers for the output of various numerical programs are contained.
For comparison with other analysis workflows pyerrors
can also generate jackknife samples from an Obs
object or import jackknife samples into an Obs
object.\nSee pyerrors.obs.Obs.export_jackknife
and pyerrors.obs.import_jackknife
for details.
Extract generic MCMC data from a bdio file
\n\nread_ADerrors requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nWrite Obs to a bdio file according to ADerrors conventions
\n\nread_mesons requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExtract mesons data from a bdio file and return it as a dictionary
\n\nThe dictionary can be accessed with a tuple consisting of (type, source_position, kappa1, kappa2)
\n\nread_mesons requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExtract dSdm data from a bdio file and return it as a dictionary
\n\nThe dictionary can be accessed with a tuple consisting of (type, kappa)
\n\nread_dSdm requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExport a list of Obs or structures containing Obs to an xml string\naccording to the Zeuthen pobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nExport a list of Obs or structures containing Obs to a .xml.gz file\naccording to the Zeuthen pobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nImport a list of Obs from an xml.gz file in the Zeuthen pobs format.
\n\nTags are not written or recovered automatically.
\n\nImport a list of Obs from a string in the Zeuthen dobs format.
\n\nTags are not written or recovered automatically.
\n\nImport a list of Obs from an xml.gz file in the Zeuthen dobs format.
\n\nTags are not written or recovered automatically.
\n\nGenerate the string for the export of a list of Obs or structures containing Obs\nto a .xml.gz file according to the Zeuthen dobs format.
\n\nTags are not written or recovered automatically. The separator |is removed from the replica names.
\n\nExport a list of Obs or structures containing Obs to a .xml.gz file\naccording to the Zeuthen dobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nRead hadrons meson hdf5 file and extract the meson labeled 'meson'
\n\nRead hadrons DistillationContraction hdf5 files in given directory structure
\n\nndarray(shape, dtype=float, buffer=None, offset=0,\n strides=None, order=None)
\n\nAn array object represents a multidimensional, homogeneous array\nof fixed-size items. An associated data-type object describes the\nformat of each element in the array (its byte-order, how many bytes it\noccupies in memory, whether it is an integer, a floating point number,\nor something else, etc.)
\n\nArrays should be constructed using array
, zeros
or empty
(refer\nto the See Also section below). The parameters given here refer to\na low-level method (ndarray(...)
) for instantiating an array.
For more information, refer to the numpy
module and examine the\nmethods and attributes of an array.
x.flat = 3
(See ndarray.flat
for\nassignment examples; TODO).itemsize * size
.(3, 4)
array of type\nint16
in C-order has strides (8, 2)
. This implies that\nto move from element to element in memory requires jumps of 2 bytes.\nTo move from row-to-row, one needs to jump 8 bytes at a time\n(2 * 4
).base
\n(unless that array is also a view). The base
array is where the\narray data is actually stored.array
: Construct an array.
\nzeros
: Create an array, each element of which is zero.
\nempty
: Create an array, but leave its allocated memory unchanged (i.e.,\nit contains \"garbage\").
\ndtype
: Create a data-type.
\nnumpy.typing.NDArray
: An ndarray alias :term:generic <generic type>
\nw.r.t. its dtype.type <numpy.dtype.type>
.
There are two modes of creating an array using __new__
:
buffer
is None, then only shape
, dtype
, and order
\nare used.buffer
is an object exposing the buffer interface, then\nall keywords are interpreted.No __init__
method is needed because the array is fully initialized\nafter the __new__
method.
These examples illustrate the low-level ndarray
constructor. Refer\nto the See Also
section above for easier ways of constructing an\nndarray.
First mode, buffer
is None:
>>> np.ndarray(shape=(2,2), dtype=float, order='F')\narray([[0.0e+000, 0.0e+000], # random\n [ nan, 2.5e-323]])\n
\nSecond mode:
\n\n>>> np.ndarray((2,), buffer=np.array([1,2,3]),\n... offset=np.int_().itemsize,\n... dtype=int) # offset = 1*itemsize, i.e. skip first element\narray([2, 3])\n
\nGamma_5 hermitean conjugate
\n\nUses the fact that the propagator is gamma5 hermitean, so just the\nin and out momenta of the propagator are exchanged.
\n"}, "pyerrors.input.hadrons.read_ExternalLeg_hd5": {"fullname": "pyerrors.input.hadrons.read_ExternalLeg_hd5", "modulename": "pyerrors.input.hadrons", "qualname": "read_ExternalLeg_hd5", "kind": "function", "doc": "Read hadrons ExternalLeg hdf5 file and output an array of CObs
\n\nRead hadrons Bilinear hdf5 file and output an array of CObs
\n\nRead hadrons FourquarkFullyConnected hdf5 file and output an array of CObs
\n\nGenerate the string for the export of a list of Obs or structures containing Obs\nto a .json(.gz) file
\n\nExport a list of Obs or structures containing Obs to a .json(.gz) file
\n\nReconstruct a list of Obs or structures containing Obs from a json string.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr\nIf the list contains only one element, it is unpacked from the list.
\n\nImport a list of Obs or structures containing Obs from a .json(.gz) file.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr\nIf the list contains only one element, it is unpacked from the list.
\n\nExport a dict of Obs or structures containing Obs to a .json(.gz) file
\n\nImport a dict of Obs or structures containing Obs from a .json(.gz) file.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr
\n\nRead pbp format from given folder structure.
\n\nRead rwms format from given folder structure. Returns a list of length nrw
\n\nExtract t0 from given .ms.dat files. Returns t0 as Obs.
\n\nIt is assumed that all boundary effects have\nsufficiently decayed at x0=xmin.\nThe data around the zero crossing of t^2
It is assumed that one measurement is performed for each config.\nIf this is not the case, the resulting idl, as well as the handling\nof r_start, r_stop and r_step is wrong and the user has to correct\nthis in the resulting observable.
\n\nRead the topologial charge based on openQCD gradient flow measurements.
\n\nRead the gradient flow coupling based on sfqcd gradient flow measurements. See 1607.06423 for details.
\n\nNote: The current implementation only works for c=0.3 and T=L. The definition of the coupling in 1607.06423 requires projection to topological charge zero which is not done within this function but has to be performed in a separate step.
\n\nReturns the projection to the topological charge sector defined by target.
\n\nConstructs reweighting factors to a specified topological sector.
\n\nRead data from files in the specified directory with the specified prefix and quark combination extension, and return a Corr
object containing the data.
**kwargs: Additional keyword arguments. The following keyword arguments are recognized:
\n\nCorr
object containing the data read from the files. In case of boudary to bulk correlators.CObs
object containing the data read from the files. In case of boudary to boundary correlators.Write DataFrame including Obs or Corr valued columns to sqlite database.
\n\nExecute SQL query on sqlite database and obtain DataFrame including Obs or Corr valued columns.
\n\nExports a pandas DataFrame containing Obs valued columns to a (gzipped) csv file.
\n\nBefore making use of pandas to_csv functionality Obs objects are serialized via the standardized\njson format of pyerrors.
\n\nImports a pandas DataFrame from a csv.(gz) file in which Obs objects are serialized as json strings.
\n\nRead sfcf files from given folder structure.
\n\nSorts a list of names of replika with searches for r
and id
in the replikum string.\nIf this search fails, a fallback method is used,\nwhere the strings are simply compared and the first diffeing numeral is used for differentiation.
Checks if list of configurations is contained in an idl
\n\nMatrix multiply all operands.
\n\nMatrix multiply both operands making use of the jackknife approximation.
\n\nWrapper for numpy.einsum
\n\nInverse of Obs or CObs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.cholesky": {"fullname": "pyerrors.linalg.cholesky", "modulename": "pyerrors.linalg", "qualname": "cholesky", "kind": "function", "doc": "Cholesky decomposition of Obs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.det": {"fullname": "pyerrors.linalg.det", "modulename": "pyerrors.linalg", "qualname": "det", "kind": "function", "doc": "Determinant of Obs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.eigh": {"fullname": "pyerrors.linalg.eigh", "modulename": "pyerrors.linalg", "qualname": "eigh", "kind": "function", "doc": "Computes the eigenvalues and eigenvectors of a given hermitian matrix of Obs according to np.linalg.eigh.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.eig": {"fullname": "pyerrors.linalg.eig", "modulename": "pyerrors.linalg", "qualname": "eig", "kind": "function", "doc": "Computes the eigenvalues of a given matrix of Obs according to np.linalg.eig.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.pinv": {"fullname": "pyerrors.linalg.pinv", "modulename": "pyerrors.linalg", "qualname": "pinv", "kind": "function", "doc": "Computes the Moore-Penrose pseudoinverse of a matrix of Obs.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.svd": {"fullname": "pyerrors.linalg.svd", "modulename": "pyerrors.linalg", "qualname": "svd", "kind": "function", "doc": "Computes the singular value decomposition of a matrix of Obs.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.misc": {"fullname": "pyerrors.misc", "modulename": "pyerrors.misc", "kind": "module", "doc": "\n"}, "pyerrors.misc.print_config": {"fullname": "pyerrors.misc.print_config", "modulename": "pyerrors.misc", "qualname": "print_config", "kind": "function", "doc": "Print information about version of python, pyerrors and dependencies.
\n", "signature": "():", "funcdef": "def"}, "pyerrors.misc.errorbar": {"fullname": "pyerrors.misc.errorbar", "modulename": "pyerrors.misc", "qualname": "errorbar", "kind": "function", "doc": "pyerrors wrapper for the errorbars method of matplotlib
\n\nDump object into pickle file.
\n\nLoad object from pickle file.
\n\nGenerate an Obs object with given value, dvalue and name for test purposes
\n\nGenerate observables with given covariance and autocorrelation times.
\n\nMatrix pencil method to extract k energy levels from data
\n\nImplementation of the matrix pencil method based on\neq. (2.17) of Y. Hua, T. K. Sarkar, IEEE Trans. Acoust. 38, 814-824 (1990)
\n\nClass for a general observable.
\n\nInstances of Obs are the basic objects of a pyerrors error analysis.\nThey are initialized with a list which contains arrays of samples for\ndifferent ensembles/replica and another list of same length which contains\nthe names of the ensembles/replica. Mathematical operations can be\nperformed on instances. The result is another instance of Obs. The error of\nan instance can be computed with the gamma_method. Also contains additional\nmethods for output and visualization of the error calculation.
\n\nInitialize Obs object.
\n\nEstimate the error and related properties of the Obs.
\n\nEstimate the error and related properties of the Obs.
\n\nOutput detailed properties of the Obs.
\n\nReweight the obs with given rewighting factors.
\n\nChecks whether the observable is zero within 'sigma' standard errors.
\n\nChecks whether the observable is zero within a given tolerance.
\n\nPlot integrated autocorrelation time for each ensemble.
\n\nPlot normalized autocorrelation function time for each ensemble.
\n\nPlot replica distribution for each ensemble with more than one replicum.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.Obs.plot_history": {"fullname": "pyerrors.obs.Obs.plot_history", "modulename": "pyerrors.obs", "qualname": "Obs.plot_history", "kind": "function", "doc": "Plot derived Monte Carlo history for each ensemble
\n\nPlot piechart which shows the fractional contribution of each\nensemble to the error and returns a dictionary containing the fractions.
\n\nDump the Obs to a file 'name' of chosen format.
\n\nExport jackknife samples from the Obs
\n\nClass for a complex valued observable.
\n"}, "pyerrors.obs.CObs.__init__": {"fullname": "pyerrors.obs.CObs.__init__", "modulename": "pyerrors.obs", "qualname": "CObs.__init__", "kind": "function", "doc": "\n", "signature": "(real, imag=0.0)"}, "pyerrors.obs.CObs.gamma_method": {"fullname": "pyerrors.obs.CObs.gamma_method", "modulename": "pyerrors.obs", "qualname": "CObs.gamma_method", "kind": "function", "doc": "Executes the gamma_method for the real and the imaginary part.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.obs.CObs.is_zero": {"fullname": "pyerrors.obs.CObs.is_zero", "modulename": "pyerrors.obs", "qualname": "CObs.is_zero", "kind": "function", "doc": "Checks whether both real and imaginary part are zero within machine precision.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.CObs.conjugate": {"fullname": "pyerrors.obs.CObs.conjugate", "modulename": "pyerrors.obs", "qualname": "CObs.conjugate", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.derived_observable": {"fullname": "pyerrors.obs.derived_observable", "modulename": "pyerrors.obs", "qualname": "derived_observable", "kind": "function", "doc": "Construct a derived Obs according to func(data, **kwargs) using automatic differentiation.
\n\nFor simple mathematical operations it can be practical to use anonymous\nfunctions. For the ratio of two observables one can e.g. use
\n\nnew_obs = derived_observable(lambda x: x[0] / x[1], [obs1, obs2])
\n", "signature": "(func, data, array_mode=False, **kwargs):", "funcdef": "def"}, "pyerrors.obs.reweight": {"fullname": "pyerrors.obs.reweight", "modulename": "pyerrors.obs", "qualname": "reweight", "kind": "function", "doc": "Reweight a list of observables.
\n\nCorrelate two observables.
\n\nKeep in mind to only correlate primary observables which have not been reweighted\nyet. The reweighting has to be applied after correlating the observables.\nCurrently only works if ensembles are identical (this is not strictly necessary).
\n", "signature": "(obs_a, obs_b):", "funcdef": "def"}, "pyerrors.obs.covariance": {"fullname": "pyerrors.obs.covariance", "modulename": "pyerrors.obs", "qualname": "covariance", "kind": "function", "doc": "Calculates the error covariance matrix of a set of observables.
\n\nWARNING: This function should be used with care, especially for observables with support on multiple\n ensembles with differing autocorrelations. See the notes below for details.
\n\nThe gamma method has to be applied first to all observables.
\n\nThe error covariance is defined such that it agrees with the squared standard error for two identical observables\n$$\\operatorname{cov}(a,a)=\\sum_{s=1}^N\\delta_a^s\\delta_a^s/N^2=\\Gamma_{aa}(0)/N=\\operatorname{var}(a)/N=\\sigma_a^2$$\nin the absence of autocorrelation.\nThe error covariance is estimated by calculating the correlation matrix assuming no autocorrelation and then rescaling the correlation matrix by the full errors including the previous gamma method estimate for the autocorrelation of the observables. The covariance at windowsize 0 is guaranteed to be positive semi-definite\n$$\\sum_{i,j}v_i\\Gamma_{ij}(0)v_j=\\frac{1}{N}\\sum_{s=1}^N\\sum_{i,j}v_i\\delta_i^s\\delta_j^s v_j=\\frac{1}{N}\\sum_{s=1}^N\\sum_{i}|v_i\\delta_i^s|^2\\geq 0\\,,$$ for every $v\\in\\mathbb{R}^M$, while such an identity does not hold for larger windows/lags.\nFor observables defined on a single ensemble our approximation is equivalent to assuming that the integrated autocorrelation time of an off-diagonal element is equal to the geometric mean of the integrated autocorrelation times of the corresponding diagonal elements.\n$$\\tau_{\\mathrm{int}, ij}=\\sqrt{\\tau_{\\mathrm{int}, i}\\times \\tau_{\\mathrm{int}, j}}$$\nThis construction ensures that the estimated covariance matrix is positive semi-definite (up to numerical rounding errors).
\n", "signature": "(obs, visualize=False, correlation=False, smooth=None, **kwargs):", "funcdef": "def"}, "pyerrors.obs.import_jackknife": {"fullname": "pyerrors.obs.import_jackknife", "modulename": "pyerrors.obs", "qualname": "import_jackknife", "kind": "function", "doc": "Imports jackknife samples and returns an Obs
\n\nCombine all observables in list_of_obs into one new observable
\n\nIt is not possible to combine obs which are based on the same replicum
\n", "signature": "(list_of_obs):", "funcdef": "def"}, "pyerrors.obs.cov_Obs": {"fullname": "pyerrors.obs.cov_Obs", "modulename": "pyerrors.obs", "qualname": "cov_Obs", "kind": "function", "doc": "Create an Obs based on mean(s) and a covariance matrix
\n\nFinds the root of the function func(x, d) where d is an Obs
.
func (object):\nFunction to be minimized. Any numpy functions have to use the autograd.numpy wrapper.\nExample:
\n\nimport autograd.numpy as anp\ndef root_func(x, d):\n return anp.exp(-x ** 2) - d\n
\nguess (float):\nInitial guess for the minimization.
Obs
valued root of the function.pyerrors
is a python package for error computation and propagation of Markov chain Monte Carlo data.\nIt is based on the gamma method arXiv:hep-lat/0306017. Some of its features are:
More detailed examples can found in the GitHub repository .
If you use pyerrors
for research that leads to a publication please consider citing:
and
\n\nwhere applicable.
\n\nThere exist similar publicly available implementations of gamma method error analysis suites in Fortran, Julia and Python.
\n\nInstall the most recent release using pip and pypi:
\n\npip install pyerrors # Fresh install\npip install -U pyerrors # Update\n
\nInstall the most recent release using conda and conda-forge:
\n\nconda install -c conda-forge pyerrors # Fresh install\nconda update -c conda-forge pyerrors # Update\n
\nInstall the current develop
version:
pip install git+https://github.com/fjosw/pyerrors.git@develop\n
\nimport numpy as np\nimport pyerrors as pe\n\nmy_obs = pe.Obs([samples], ['ensemble_name']) # Initialize an Obs object\nmy_new_obs = 2 * np.log(my_obs) / my_obs ** 2 # Construct derived Obs object\nmy_new_obs.gamma_method() # Estimate the statistical error\nprint(my_new_obs) # Print the result to stdout\n> 0.31498(72)\n
\nObs
classpyerrors
introduces a new datatype, Obs
, which simplifies error propagation and estimation for auto- and cross-correlated data.\nAn Obs
object can be initialized with two arguments, the first is a list containing the samples for an observable from a Monte Carlo chain.\nThe samples can either be provided as python list or as numpy array.\nThe second argument is a list containing the names of the respective Monte Carlo chains as strings. These strings uniquely identify a Monte Carlo chain/ensemble. It is crucial for the correct error propagation that observations from the same Monte Carlo history are labeled with the same name. See Multiple ensembles/replica for details.
import pyerrors as pe\n\nmy_obs = pe.Obs([samples], ['ensemble_name'])\n
\nWhen performing mathematical operations on Obs
objects the correct error propagation is intrinsically taken care of using a first order Taylor expansion\n$$\\delta_f^i=\\sum_\\alpha \\bar{f}_\\alpha \\delta_\\alpha^i\\,,\\quad \\delta_\\alpha^i=a_\\alpha^i-\\bar{a}_\\alpha\\,,$$\nas introduced in arXiv:hep-lat/0306017.\nThe required derivatives $\\bar{f}_\\alpha$ are evaluated up to machine precision via automatic differentiation as suggested in arXiv:1809.01289.
The Obs
class is designed such that mathematical numpy functions can be used on Obs
just as for regular floats.
import numpy as np\nimport pyerrors as pe\n\nmy_obs1 = pe.Obs([samples1], ['ensemble_name'])\nmy_obs2 = pe.Obs([samples2], ['ensemble_name'])\n\nmy_sum = my_obs1 + my_obs2\n\nmy_m_eff = np.log(my_obs1 / my_obs2)\n\niamzero = my_m_eff - my_m_eff\n# Check that value and fluctuations are zero within machine precision\nprint(iamzero == 0.0)\n> True\n
\nThe error estimation within pyerrors
is based on the gamma method introduced in arXiv:hep-lat/0306017.\nAfter having arrived at the derived quantity of interest the gamma_method
can be called as detailed in the following example.
my_sum.gamma_method()\nprint(my_sum)\n> 1.70(57)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 5.72046658e-01 +/- 7.56746598e-02 (33.650%)\n> t_int 2.71422900e+00 +/- 6.40320983e-01 S = 2.00\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nWe use the following definition of the integrated autocorrelation time established in Madras & Sokal 1988\n$$\\tau_\\mathrm{int}=\\frac{1}{2}+\\sum_{t=1}^{W}\\rho(t)\\geq \\frac{1}{2}\\,.$$\nThe window $W$ is determined via the automatic windowing procedure described in arXiv:hep-lat/0306017.\nThe standard value for the parameter $S$ of this automatic windowing procedure is $S=2$. Other values for $S$ can be passed to the gamma_method
as parameter.
my_sum.gamma_method(S=3.0)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 6.30675201e-01 +/- 1.04585650e-01 (37.099%)\n> t_int 3.29909703e+00 +/- 9.77310102e-01 S = 3.00\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nThe integrated autocorrelation time $\\tau_\\mathrm{int}$ and the autocorrelation function $\\rho(W)$ can be monitored via the methods pyerrors.obs.Obs.plot_tauint
and pyerrors.obs.Obs.plot_rho
.
If the parameter $S$ is set to zero it is assumed that the dataset does not exhibit any autocorrelation and the window size is chosen to be zero.\nIn this case the error estimate is identical to the sample standard error.
\n\nSlow modes in the Monte Carlo history can be accounted for by attaching an exponential tail to the autocorrelation function $\\rho$ as suggested in arXiv:1009.5228. The longest autocorrelation time in the history, $\\tau_\\mathrm{exp}$, can be passed to the gamma_method
as parameter. In this case the automatic windowing procedure is vacated and the parameter $S$ does not affect the error estimate.
my_sum.gamma_method(tau_exp=7.2)\nmy_sum.details()\n> Result 1.70000000e+00 +/- 6.28097762e-01 +/- 5.79077524e-02 (36.947%)\n> t_int 3.27218667e+00 +/- 7.99583654e-01 tau_exp = 7.20, N_sigma = 1\n> 1000 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)\n
\nFor the full API see pyerrors.obs.Obs.gamma_method
.
Error propagation for multiple ensembles (Markov chains with different simulation parameters) is handled automatically. Ensembles are uniquely identified by their name
.
obs1 = pe.Obs([samples1], ['ensemble1'])\nobs2 = pe.Obs([samples2], ['ensemble2'])\n\nmy_sum = obs1 + obs2\nmy_sum.details()\n> Result 2.00697958e+00\n> 1500 samples in 2 ensembles:\n> \u00b7 Ensemble 'ensemble1' : 1000 configurations (from 1 to 1000)\n> \u00b7 Ensemble 'ensemble2' : 500 configurations (from 1 to 500)\n
\nObservables from the same Monte Carlo chain have to be initialized with the same name for correct error propagation. If different names were used in this case the data would be treated as statistically independent resulting in loss of relevant information and a potential over or under estimate of the statistical error.
\n\npyerrors
identifies multiple replica (independent Markov chains with identical simulation parameters) by the vertical bar |
in the name of the data set.
obs1 = pe.Obs([samples1], ['ensemble1|r01'])\nobs2 = pe.Obs([samples2], ['ensemble1|r02'])\n\n> my_sum = obs1 + obs2\n> my_sum.details()\n> Result 2.00697958e+00\n> 1500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1'\n> \u00b7 Replicum 'r01' : 1000 configurations (from 1 to 1000)\n> \u00b7 Replicum 'r02' : 500 configurations (from 1 to 500)\n
\nIn order to keep track of different error analysis parameters for different ensembles one can make use of global dictionaries as detailed in the following example.
\n\npe.Obs.S_dict['ensemble1'] = 2.5\npe.Obs.tau_exp_dict['ensemble2'] = 8.0\npe.Obs.tau_exp_dict['ensemble3'] = 2.0\n
\nIn case the gamma_method
is called without any parameters it will use the values specified in the dictionaries for the respective ensembles.\nPassing arguments to the gamma_method
still dominates over the dictionaries.
Obs
objects defined on irregular Monte Carlo chains can be initialized with the parameter idl
.
# Observable defined on configurations 20 to 519\nobs1 = pe.Obs([samples1], ['ensemble1'], idl=[range(20, 520)])\nobs1.details()\n> Result 9.98319881e-01\n> 500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 500 configurations (from 20 to 519)\n\n# Observable defined on every second configuration between 5 and 1003\nobs2 = pe.Obs([samples2], ['ensemble1'], idl=[range(5, 1005, 2)])\nobs2.details()\n> Result 9.99100712e-01\n> 500 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 500 configurations (from 5 to 1003 in steps of 2)\n\n# Observable defined on configurations 2, 9, 28, 29 and 501\nobs3 = pe.Obs([samples3], ['ensemble1'], idl=[[2, 9, 28, 29, 501]])\nobs3.details()\n> Result 1.01718064e+00\n> 5 samples in 1 ensemble:\n> \u00b7 Ensemble 'ensemble1' : 5 configurations (irregular range)\n
\nObs
objects defined on regular and irregular histories of the same ensemble can be combined with each other and the correct error propagation and estimation is automatically taken care of.
Warning: Irregular Monte Carlo chains can result in odd patterns in the autocorrelation functions.\nMake sure to check the autocorrelation time with e.g. pyerrors.obs.Obs.plot_rho
or pyerrors.obs.Obs.plot_tauint
.
For the full API see pyerrors.obs.Obs
.
When one is not interested in single observables but correlation functions, pyerrors
offers the Corr
class which simplifies the corresponding error propagation and provides the user with a set of standard methods. In order to initialize a Corr
objects one needs to arrange the data as a list of Obs
my_corr = pe.Corr([obs_0, obs_1, obs_2, obs_3])\nprint(my_corr)\n> x0/a Corr(x0/a)\n> ------------------\n> 0 0.7957(80)\n> 1 0.5156(51)\n> 2 0.3227(33)\n> 3 0.2041(21)\n
\nIn case the correlation functions are not defined on the outermost timeslices, for example because of fixed boundary conditions, a padding can be introduced.
\n\nmy_corr = pe.Corr([obs_0, obs_1, obs_2, obs_3], padding=[1, 1])\nprint(my_corr)\n> x0/a Corr(x0/a)\n> ------------------\n> 0\n> 1 0.7957(80)\n> 2 0.5156(51)\n> 3 0.3227(33)\n> 4 0.2041(21)\n> 5\n
\nThe individual entries of a correlator can be accessed via slicing
\n\nprint(my_corr[3])\n> 0.3227(33)\n
\nError propagation with the Corr
class works very similar to Obs
objects. Mathematical operations are overloaded and Corr
objects can be computed together with other Corr
objects, Obs
objects or real numbers and integers.
my_new_corr = 0.3 * my_corr[2] * my_corr * my_corr + 12 / my_corr\n
\npyerrors
provides the user with a set of regularly used methods for the manipulation of correlator objects:
Corr.gamma_method
applies the gamma method to all entries of the correlator.Corr.m_eff
to construct effective masses. Various variants for periodic and fixed temporal boundary conditions are available.Corr.deriv
returns the first derivative of the correlator as Corr
. Different discretizations of the numerical derivative are available.Corr.second_deriv
returns the second derivative of the correlator as Corr
. Different discretizations of the numerical derivative are available.Corr.symmetric
symmetrizes parity even correlations functions, assuming periodic boundary conditions.Corr.anti_symmetric
anti-symmetrizes parity odd correlations functions, assuming periodic boundary conditions.Corr.T_symmetry
averages a correlator with its time symmetry partner, assuming fixed boundary conditions.Corr.plateau
extracts a plateau value from the correlator in a given range.Corr.roll
periodically shifts the correlator.Corr.reverse
reverses the time ordering of the correlator.Corr.correlate
constructs a disconnected correlation function from the correlator and another Corr
or Obs
object.Corr.reweight
reweights the correlator.pyerrors
can also handle matrices of correlation functions and extract energy states from these matrices via a generalized eigenvalue problem (see pyerrors.correlators.Corr.GEVP
).
For the full API see pyerrors.correlators.Corr
.
pyerrors
can handle complex valued observables via the class pyerrors.obs.CObs
.\nCObs
are initialized with a real and an imaginary part which both can be Obs
valued.
my_real_part = pe.Obs([samples1], ['ensemble1'])\nmy_imag_part = pe.Obs([samples2], ['ensemble1'])\n\nmy_cobs = pe.CObs(my_real_part, my_imag_part)\nmy_cobs.gamma_method()\nprint(my_cobs)\n> (0.9959(91)+0.659(28)j)\n
\nElementary mathematical operations are overloaded and samples are properly propagated as for the Obs
class.
my_derived_cobs = (my_cobs + my_cobs.conjugate()) / np.abs(my_cobs)\nmy_derived_cobs.gamma_method()\nprint(my_derived_cobs)\n> (1.668(23)+0.0j)\n
\nCovobs
classIn many projects, auxiliary data that is not based on Monte Carlo chains enters. Examples are experimentally determined mesons masses which are used to set the scale or renormalization constants. These numbers come with an error that has to be propagated through the analysis. The Covobs
class allows to define such quantities in pyerrors
. Furthermore, external input might consist of correlated quantities. An example are the parameters of an interpolation formula, which are defined via mean values and a covariance matrix between all parameters. The contribution of the interpolation formula to the error of a derived quantity therefore might depend on the complete covariance matrix.
This concept is built into the definition of Covobs
. In pyerrors
, external input is defined by $M$ mean values, a $M\\times M$ covariance matrix, where $M=1$ is permissible, and a name that uniquely identifies the covariance matrix. Below, we define the pion mass, based on its mean value and error, 134.9768(5). Note, that the square of the error enters cov_Obs
, since the second argument of this function is the covariance matrix of the Covobs
.
import pyerrors.obs as pe\n\nmpi = pe.cov_Obs(134.9768, 0.0005**2, 'pi^0 mass')\nmpi.gamma_method()\nmpi.details()\n> Result 1.34976800e+02 +/- 5.00000000e-04 +/- 0.00000000e+00 (0.000%)\n> pi^0 mass 5.00000000e-04\n> 0 samples in 1 ensemble:\n> \u00b7 Covobs 'pi^0 mass'\n
\nThe resulting object mpi
is an Obs
that contains a Covobs
. In the following, it may be handled as any other Obs
. The contribution of the covariance matrix to the error of an Obs
is determined from the $M \\times M$ covariance matrix $\\Sigma$ and the gradient of the Obs
with respect to the external quantities, which is the $1\\times M$ Jacobian matrix $J$, via\n$$s = \\sqrt{J^T \\Sigma J}\\,,$$\nwhere the Jacobian is computed for each derived quantity via automatic differentiation.
Correlated auxiliary data is defined similarly to above, e.g., via
\n\nRAP = pe.cov_Obs([16.7457, -19.0475], [[3.49591, -6.07560], [-6.07560, 10.5834]], 'R_AP, 1906.03445, (5.3a)')\nprint(RAP)\n> [Obs[16.7(1.9)], Obs[-19.0(3.3)]]\n
\nwhere RAP
now is a list of two Obs
that contains the two correlated parameters.
Since the gradient of a derived observable with respect to an external covariance matrix is propagated through the entire analysis, the Covobs
class allows to quote the derivative of a result with respect to the external quantities. If these derivatives are published together with the result, small shifts in the definition of external quantities, e.g., the definition of the physical point, can be performed a posteriori based on the published information. This may help to compare results of different groups. The gradient of an Obs
o
with respect to a covariance matrix with the identifying string k
may be accessed via
o.covobs[k].grad\n
\npyerrors
supports exact linear error propagation for iterative algorithms like various variants of non-linear least squares fits or root finding. The derivatives required for the error propagation are calculated as described in arXiv:1809.01289.
Standard non-linear least square fits with errors on the dependent but not the independent variables can be performed with pyerrors.fits.least_squares
. As default solver the Levenberg-Marquardt algorithm implemented in scipy is used.
Fit functions have to be of the following form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[1] * anp.exp(-a[0] * x)\n
\nIt is important that numerical functions refer to autograd.numpy
instead of numpy
for the automatic differentiation in iterative algorithms to work properly.
Fits can then be performed via
\n\nfit_result = pe.fits.least_squares(x, y, func)\nprint("\\n", fit_result)\n> Fit with 2 parameters\n> Method: Levenberg-Marquardt\n> `ftol` termination condition is satisfied.\n> chisquare/d.o.f.: 0.9593035785160936\n\n> Goodness of fit:\n> \u03c7\u00b2/d.o.f. = 0.959304\n> p-value = 0.5673\n> Fit parameters:\n> 0 0.0548(28)\n> 1 1.933(64)\n
\nwhere x is a list
or numpy.array
of floats
and y is a list
or numpy.array
of Obs
.
Data stored in Corr
objects can be fitted directly using the Corr.fit
method.
my_corr = pe.Corr(y)\nfit_result = my_corr.fit(func, fitrange=[12, 25])\n
\nthis can simplify working with absolute fit ranges and takes care of gaps in the data automatically.
\n\nFor fit functions with multiple independent variables the fit function can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\npyerrors
also supports correlated fits which can be triggered via the parameter correlated_fit=True
.\nDetails about how the required covariance matrix is estimated can be found in pyerrors.obs.covariance
.
Direct visualizations of the performed fits can be triggered via resplot=True
or qqplot=True
. For all available options see pyerrors.fits.least_squares
.
pyerrors
can also fit data with errors on both the dependent and independent variables using the total least squares method also referred to orthogonal distance regression as implemented in scipy, see pyerrors.fits.least_squares
. The syntax is identical to the standard least squares case, the only difference being that x
also has to be a list
or numpy.array
of Obs
.
For the full API see pyerrors.fits
for fits and pyerrors.roots
for finding roots of functions.
pyerrors
provides wrappers for Obs
- and CObs
-valued matrix operations based on numpy.linalg
. The supported functions include:
inv
for the matrix inverse.cholseky
for the Cholesky decomposition.det
for the matrix determinant.eigh
for eigenvalues and eigenvectors of hermitean matrices.eig
for eigenvalues of general matrices.pinv
for the Moore-Penrose pseudoinverse.svd
for the singular-value-decomposition.For the full API see pyerrors.linalg
.
The preferred exported file format within pyerrors
is json.gz. Files written to this format are valid JSON files that have been compressed using gzip. The structure of the content is inspired by the dobs format of the ALPHA collaboration. The aim of the format is to facilitate the storage of data in a self-contained way such that, even years after the creation of the file, it is possible to extract all necessary information:
This can be achieved by storing all information in one single file. The export routines of pyerrors
are written such that as much information as possible is written automatically as described in the following example
my_obs = pe.Obs([samples], ["test_ensemble"])\nmy_obs.tag = "My observable"\n\npe.input.json.dump_to_json(my_obs, "test_output_file", description="This file contains a test observable")\n# For a single observable one can equivalently use the class method dump\nmy_obs.dump("test_output_file", description="This file contains a test observable")\n\ncheck = pe.input.json.load_json("test_output_file")\n\nprint(my_obs == check)\n> True\n
\nThe format also allows to directly write out the content of Corr
objects or lists and arrays of Obs
objects by passing the desired data to pyerrors.input.json.dump_to_json
.
The first entries of the file provide optional auxiliary information:
\n\nprogram
is a string that indicates which program was used to write the file.version
is a string that specifies the version of the format.who
is a string that specifies the user name of the creator of the file.date
is a string and contains the creation date of the file.host
is a string and contains the hostname of the machine where the file has been written.description
contains information on the content of the file. This field is not filled automatically in pyerrors
. The user is advised to provide as detailed information as possible in this field. Examples are: Input files of measurements or simulations, LaTeX formulae or references to publications to specify how the observables have been computed, details on the analysis strategy, ... This field may be any valid JSON type. Strings, arrays or objects (equivalent to dicts in python) are well suited to provide information.The only necessary entry of the file is the field\n-obsdata
, an array that contains the actual data.
Each entry of the array belongs to a single structure of observables. Currently, these structures can be either of Obs
, list
, numpy.ndarray
, Corr
. All Obs
inside a structure (with dimension > 0) have to be defined on the same set of configurations. Different structures, that are represented by entries of the array obsdata
, are treated independently. Each entry of the array obsdata
has the following required entries:
type
is a string that specifies the type of the structure. This allows to parse the content to the correct form after reading the file. It is always possible to interpret the content as list of Obs.value
is an array that contains the mean values of the Obs inside the structure.\nThe following entries are optional:layout
is a string that specifies the layout of multi-dimensional structures. Examples are \"2, 2\" for a 2x2 dimensional matrix or \"64, 4, 4\" for a Corr with $T=64$ and 4x4 matrices on each time slices. \"1\" denotes a single Obs. Multi-dimensional structures are stored in row-major format (see below).tag
is any JSON type. It contains additional information concerning the structure. The tag
of an Obs
in pyerrors
is written here.reweighted
is a Bool that may be used to specify, whether the Obs
in the structure have been reweighted.data
is an array that contains the data from MC chains. We will define it below.cdata
is an array that contains the data from external quantities with an error (Covobs
in pyerrors
). We will define it below.The array data
contains the data from MC chains. Each entry of the array corresponds to one ensemble and contains:
id
, a string that contains the name of the ensemblereplica
, an array that contains an entry per replica of the ensemble.Each entry of replica
contains\nname
, a string that contains the name of the replica\ndeltas
, an array that contains the actual data.
Each entry in deltas
corresponds to one configuration of the replica and has $1+N$ many entries. The first entry is an integer that specifies the configuration number that, together with ensemble and replica name, may be used to uniquely identify the configuration on which the data has been obtained. The following N entries specify the deltas, i.e., the deviation of the observable from the mean value on this configuration, of each Obs
inside the structure. Multi-dimensional structures are stored in a row-major format. For primary observables, such as correlation functions, $value + delta_i$ matches the primary data obtained on the configuration.
The array cdata
contains information about the contribution of auxiliary observables, represented by Covobs
in pyerrors
, to the total error of the observables. Each entry of the array belongs to one auxiliary covariance matrix and contains:
id
, a string that identifies the covariance matrixlayout
, a string that defines the dimensions of the $M\\times M$ covariance matrix (has to be \"M, M\" or \"1\").cov
, an array that contains the $M\\times M$ many entries of the covariance matrix, stored in row-major format.grad
, an array that contains N entries, one for each Obs
inside the structure. Each entry itself is an array, that contains the M gradients of the Nth observable with respect to the quantity that corresponds to the Mth diagonal entry of the covariance matrix.A JSON schema that may be used to verify the correctness of a file with respect to the format definition is stored in ./examples/json_schema.json. The schema is a self-descriptive format definition and contains an exemplary file.
\n\nJulia I/O routines for the json.gz format, compatible with ADerrors.jl, can be found here.
\n"}, "pyerrors.correlators": {"fullname": "pyerrors.correlators", "modulename": "pyerrors.correlators", "kind": "module", "doc": "\n"}, "pyerrors.correlators.Corr": {"fullname": "pyerrors.correlators.Corr", "modulename": "pyerrors.correlators", "qualname": "Corr", "kind": "class", "doc": "The class for a correlator (time dependent sequence of pe.Obs).
\n\nEverything, this class does, can be achieved using lists or arrays of Obs.\nBut it is simply more convenient to have a dedicated object for correlators.\nOne often wants to add or multiply correlators of the same length at every timeslice and it is inconvenient\nto iterate over all timeslices for every operation. This is especially true, when dealing with matrices.
\n\nThe correlator can have two types of content: An Obs at every timeslice OR a GEVP\nmatrix at every timeslice. Other dependency (eg. spatial) are not supported.
\n"}, "pyerrors.correlators.Corr.__init__": {"fullname": "pyerrors.correlators.Corr.__init__", "modulename": "pyerrors.correlators", "qualname": "Corr.__init__", "kind": "function", "doc": "Initialize a Corr object.
\n\nApply the gamma method to the content of the Corr.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.correlators.Corr.gm": {"fullname": "pyerrors.correlators.Corr.gm", "modulename": "pyerrors.correlators", "qualname": "Corr.gm", "kind": "function", "doc": "Apply the gamma method to the content of the Corr.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.correlators.Corr.projected": {"fullname": "pyerrors.correlators.Corr.projected", "modulename": "pyerrors.correlators", "qualname": "Corr.projected", "kind": "function", "doc": "We need to project the Correlator with a Vector to get a single value at each timeslice.
\n\nThe method can use one or two vectors.\nIf two are specified it returns v1@G@v2 (the order might be very important.)\nBy default it will return the lowest source, which usually means unsmeared-unsmeared (0,0), but it does not have to
\n", "signature": "(self, vector_l=None, vector_r=None, normalize=False):", "funcdef": "def"}, "pyerrors.correlators.Corr.item": {"fullname": "pyerrors.correlators.Corr.item", "modulename": "pyerrors.correlators", "qualname": "Corr.item", "kind": "function", "doc": "Picks the element [i,j] from every matrix and returns a correlator containing one Obs per timeslice.
\n\nOutputs the correlator in a plotable format.
\n\nOutputs three lists containing the timeslice index, the value on each\ntimeslice and the error on each timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.symmetric": {"fullname": "pyerrors.correlators.Corr.symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.symmetric", "kind": "function", "doc": "Symmetrize the correlator around x0=0.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.anti_symmetric": {"fullname": "pyerrors.correlators.Corr.anti_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.anti_symmetric", "kind": "function", "doc": "Anti-symmetrize the correlator around x0=0.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.is_matrix_symmetric": {"fullname": "pyerrors.correlators.Corr.is_matrix_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.is_matrix_symmetric", "kind": "function", "doc": "Checks whether a correlator matrices is symmetric on every timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.matrix_symmetric": {"fullname": "pyerrors.correlators.Corr.matrix_symmetric", "modulename": "pyerrors.correlators", "qualname": "Corr.matrix_symmetric", "kind": "function", "doc": "Symmetrizes the correlator matrices on every timeslice.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.GEVP": {"fullname": "pyerrors.correlators.Corr.GEVP", "modulename": "pyerrors.correlators", "qualname": "Corr.GEVP", "kind": "function", "doc": "Solve the generalized eigenvalue problem on the correlator matrix and returns the corresponding eigenvectors.
\n\nThe eigenvectors are sorted according to the descending eigenvalues, the zeroth eigenvector(s) correspond to the\nlargest eigenvalue(s). The eigenvector(s) for the individual states can be accessed via slicing
\n\nC.GEVP(t0=2)[0] # Ground state vector(s)\nC.GEVP(t0=2)[:3] # Vectors for the lowest three states\n
\nDetermines the eigenvalue of the GEVP by solving and projecting the correlator
\n\nConstructs an NxN Hankel matrix
\n\nC(t) c(t+1) ... c(t+n-1)\nC(t+1) c(t+2) ... c(t+n)\n.................\nC(t+(n-1)) c(t+n) ... c(t+2(n-1))
\n\nPeriodically shift the correlator by dt timeslices
\n\nReverse the time ordering of the Corr
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.correlators.Corr.thin": {"fullname": "pyerrors.correlators.Corr.thin", "modulename": "pyerrors.correlators", "qualname": "Corr.thin", "kind": "function", "doc": "Thin out a correlator to suppress correlations
\n\nCorrelate the correlator with another correlator or Obs
\n\nReweight the correlator.
\n\nReturn the time symmetry average of the correlator and its partner
\n\nReturn the first derivative of the correlator with respect to x0.
\n\nReturn the second derivative of the correlator with respect to x0.
\n\nReturns the effective mass of the correlator as correlator object
\n\nFits function to the data
\n\nfitrange=[4, 6]
corresponds to the three entries 4, 5 and 6.\nIf not specified, self.prange or all timeslices are used.Extract a plateau value from a Corr object
\n\nSets the attribute prange of the Corr object.
\n", "signature": "(self, prange):", "funcdef": "def"}, "pyerrors.correlators.Corr.show": {"fullname": "pyerrors.correlators.Corr.show", "modulename": "pyerrors.correlators", "qualname": "Corr.show", "kind": "function", "doc": "Plots the correlator using the tag of the correlator as label if available.
\n\nProduces a spaghetti plot of the correlator suited to monitor exceptional configurations.
\n\nDumps the Corr into a file of chosen type
\n\nProject large correlation matrix to lowest states
\n\nThis method can be used to reduce the size of an (N x N) correlation matrix\nto (Ntrunc x Ntrunc) by solving a GEVP at very early times where the noise\nis still small.
\n\nWe have the basematrix $C(t)$ and the target matrix $G(t)$. We start by solving\nthe GEVP $$C(t) v_n(t, t_0) = \\lambda_n(t, t_0) C(t_0) v_n(t, t_0)$$ where $t \\equiv t_\\mathrm{proj}$\nand $t_0 \\equiv t_{0, \\mathrm{proj}}$. The target matrix is projected onto the subspace of the\nresulting eigenvectors $v_n, n=1,\\dots,N_\\mathrm{trunc}$ via\n$$G^\\prime_{i, j}(t) = (v_i, G(t) v_j)$$. This allows to reduce the size of a large\ncorrelation matrix and to remove some noise that is added by irrelevant operators.\nThis may allow to use the GEVP on $G(t)$ at late times such that the theoretically motivated\nbound $t_0 \\leq t/2$ holds, since the condition number of $G(t)$ is decreased, compared to $C(t)$.
\n", "signature": "(self, Ntrunc, tproj=3, t0proj=2, basematrix=None):", "funcdef": "def"}, "pyerrors.covobs": {"fullname": "pyerrors.covobs", "modulename": "pyerrors.covobs", "kind": "module", "doc": "\n"}, "pyerrors.covobs.Covobs": {"fullname": "pyerrors.covobs.Covobs", "modulename": "pyerrors.covobs", "qualname": "Covobs", "kind": "class", "doc": "\n"}, "pyerrors.covobs.Covobs.__init__": {"fullname": "pyerrors.covobs.Covobs.__init__", "modulename": "pyerrors.covobs", "qualname": "Covobs.__init__", "kind": "function", "doc": "Initialize Covobs object.
\n\nReturn the variance (= square of the error) of the Covobs
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.dirac": {"fullname": "pyerrors.dirac", "modulename": "pyerrors.dirac", "kind": "module", "doc": "\n"}, "pyerrors.dirac.epsilon_tensor": {"fullname": "pyerrors.dirac.epsilon_tensor", "modulename": "pyerrors.dirac", "qualname": "epsilon_tensor", "kind": "function", "doc": "Rank-3 epsilon tensor
\n\nBased on https://codegolf.stackexchange.com/a/160375
\n\nRank-4 epsilon tensor
\n\nExtension of https://codegolf.stackexchange.com/a/160375
\n\nReturns gamma matrix in Grid labeling.
\n", "signature": "(gamma_tag):", "funcdef": "def"}, "pyerrors.fits": {"fullname": "pyerrors.fits", "modulename": "pyerrors.fits", "kind": "module", "doc": "\n"}, "pyerrors.fits.Fit_result": {"fullname": "pyerrors.fits.Fit_result", "modulename": "pyerrors.fits", "qualname": "Fit_result", "kind": "class", "doc": "Represents fit results.
\n\nApply the gamma method to all fit parameters
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.fits.Fit_result.gm": {"fullname": "pyerrors.fits.Fit_result.gm", "modulename": "pyerrors.fits", "qualname": "Fit_result.gm", "kind": "function", "doc": "Apply the gamma method to all fit parameters
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.fits.least_squares": {"fullname": "pyerrors.fits.least_squares", "modulename": "pyerrors.fits", "qualname": "least_squares", "kind": "function", "doc": "Performs a non-linear fit to y = func(x).\n ```
\n\nfunc (object):\nfit function, has to be of the form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[0] + a[1] * x + a[2] * anp.sinh(x)\n
\nFor multiple x values func can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
funcs (dict):\ndict of objects\nfit functions have to be of the form (here a[0] is the common fit parameter)\n```python\nimport autograd.numpy as anp\nfuncs = {\"a\": func_a,\n \"b\": func_b}
\n\ndef func_a(a, x):\n return a[1] * anp.exp(-a[0] * x)
\n\ndef func_b(a, x):\n return a[2] * anp.exp(-a[0] * x)
\n\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
pyerrors.obs.covariance
.\nIn practice the correlation matrix is Cholesky decomposed and inverted (instead of the covariance matrix).\nThis procedure should be numerically more stable as the correlation matrix is typically better conditioned (Jacobi preconditioning).Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.
\n\nfunc (object):\nfunc has to be of the form
\n\nimport autograd.numpy as anp\n\ndef func(a, x):\n return a[0] + a[1] * x + a[2] * anp.sinh(x)\n
\nFor multiple x values func can be of the form
\n\ndef func(a, x):\n (x1, x2) = x\n return a[0] * x1 ** 2 + a[1] * x2\n
\nIt is important that all numpy functions refer to autograd.numpy, otherwise the differentiation\nwill not work.
Based on the orthogonal distance regression module of scipy.
\n\nPerforms a linear fit to y = n + m * x and returns two Obs n, m.
\n\nGenerates a quantile-quantile plot of the fit result which can be used to\n check if the residuals of the fit are gaussian distributed.
\n\nGenerates a plot which compares the fit to the data and displays the corresponding residuals
\n\nFor uncorrelated data the residuals are expected to be distributed ~N(0,1).
\n\nCalculate the error band for an array of sample values x, for given fit function func with optimized parameters beta.
\n\nPerforms a Kolmogorov\u2013Smirnov test for the p-values of all fit object.
\n\npyerrors
includes an input
submodule in which input routines and parsers for the output of various numerical programs are contained.
For comparison with other analysis workflows pyerrors
can also generate jackknife samples from an Obs
object or import jackknife samples into an Obs
object.\nSee pyerrors.obs.Obs.export_jackknife
and pyerrors.obs.import_jackknife
for details.
Extract generic MCMC data from a bdio file
\n\nread_ADerrors requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nWrite Obs to a bdio file according to ADerrors conventions
\n\nread_mesons requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExtract mesons data from a bdio file and return it as a dictionary
\n\nThe dictionary can be accessed with a tuple consisting of (type, source_position, kappa1, kappa2)
\n\nread_mesons requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExtract dSdm data from a bdio file and return it as a dictionary
\n\nThe dictionary can be accessed with a tuple consisting of (type, kappa)
\n\nread_dSdm requires bdio to be compiled into a shared library. This can be achieved by\nadding the flag -fPIC to CC and changing the all target to
\n\nall: bdio.o $(LIBDIR)\n gcc -shared -Wl,-soname,libbdio.so -o $(BUILDDIR)/libbdio.so $(BUILDDIR)/bdio.o\n cp $(BUILDDIR)/libbdio.so $(LIBDIR)/
\n\nExport a list of Obs or structures containing Obs to an xml string\naccording to the Zeuthen pobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nExport a list of Obs or structures containing Obs to a .xml.gz file\naccording to the Zeuthen pobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nImport a list of Obs from an xml.gz file in the Zeuthen pobs format.
\n\nTags are not written or recovered automatically.
\n\nImport a list of Obs from a string in the Zeuthen dobs format.
\n\nTags are not written or recovered automatically.
\n\nImport a list of Obs from an xml.gz file in the Zeuthen dobs format.
\n\nTags are not written or recovered automatically.
\n\nGenerate the string for the export of a list of Obs or structures containing Obs\nto a .xml.gz file according to the Zeuthen dobs format.
\n\nTags are not written or recovered automatically. The separator |is removed from the replica names.
\n\nExport a list of Obs or structures containing Obs to a .xml.gz file\naccording to the Zeuthen dobs format.
\n\nTags are not written or recovered automatically. The separator | is removed from the replica names.
\n\nRead hadrons meson hdf5 file and extract the meson labeled 'meson'
\n\nRead hadrons DistillationContraction hdf5 files in given directory structure
\n\nndarray(shape, dtype=float, buffer=None, offset=0,\n strides=None, order=None)
\n\nAn array object represents a multidimensional, homogeneous array\nof fixed-size items. An associated data-type object describes the\nformat of each element in the array (its byte-order, how many bytes it\noccupies in memory, whether it is an integer, a floating point number,\nor something else, etc.)
\n\nArrays should be constructed using array
, zeros
or empty
(refer\nto the See Also section below). The parameters given here refer to\na low-level method (ndarray(...)
) for instantiating an array.
For more information, refer to the numpy
module and examine the\nmethods and attributes of an array.
x.flat = 3
(See ndarray.flat
for\nassignment examples; TODO).itemsize * size
.(3, 4)
array of type\nint16
in C-order has strides (8, 2)
. This implies that\nto move from element to element in memory requires jumps of 2 bytes.\nTo move from row-to-row, one needs to jump 8 bytes at a time\n(2 * 4
).base
\n(unless that array is also a view). The base
array is where the\narray data is actually stored.array
: Construct an array.
\nzeros
: Create an array, each element of which is zero.
\nempty
: Create an array, but leave its allocated memory unchanged (i.e.,\nit contains \"garbage\").
\ndtype
: Create a data-type.
\nnumpy.typing.NDArray
: An ndarray alias :term:generic <generic type>
\nw.r.t. its dtype.type <numpy.dtype.type>
.
There are two modes of creating an array using __new__
:
buffer
is None, then only shape
, dtype
, and order
\nare used.buffer
is an object exposing the buffer interface, then\nall keywords are interpreted.No __init__
method is needed because the array is fully initialized\nafter the __new__
method.
These examples illustrate the low-level ndarray
constructor. Refer\nto the See Also
section above for easier ways of constructing an\nndarray.
First mode, buffer
is None:
>>> np.ndarray(shape=(2,2), dtype=float, order='F')\narray([[0.0e+000, 0.0e+000], # random\n [ nan, 2.5e-323]])\n
\nSecond mode:
\n\n>>> np.ndarray((2,), buffer=np.array([1,2,3]),\n... offset=np.int_().itemsize,\n... dtype=int) # offset = 1*itemsize, i.e. skip first element\narray([2, 3])\n
\nGamma_5 hermitean conjugate
\n\nUses the fact that the propagator is gamma5 hermitean, so just the\nin and out momenta of the propagator are exchanged.
\n"}, "pyerrors.input.hadrons.read_ExternalLeg_hd5": {"fullname": "pyerrors.input.hadrons.read_ExternalLeg_hd5", "modulename": "pyerrors.input.hadrons", "qualname": "read_ExternalLeg_hd5", "kind": "function", "doc": "Read hadrons ExternalLeg hdf5 file and output an array of CObs
\n\nRead hadrons Bilinear hdf5 file and output an array of CObs
\n\nRead hadrons FourquarkFullyConnected hdf5 file and output an array of CObs
\n\nGenerate the string for the export of a list of Obs or structures containing Obs\nto a .json(.gz) file
\n\nExport a list of Obs or structures containing Obs to a .json(.gz) file
\n\nReconstruct a list of Obs or structures containing Obs from a json string.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr\nIf the list contains only one element, it is unpacked from the list.
\n\nImport a list of Obs or structures containing Obs from a .json(.gz) file.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr\nIf the list contains only one element, it is unpacked from the list.
\n\nExport a dict of Obs or structures containing Obs to a .json(.gz) file
\n\nImport a dict of Obs or structures containing Obs from a .json(.gz) file.
\n\nThe following structures are supported: Obs, list, numpy.ndarray, Corr
\n\nRead pbp format from given folder structure.
\n\nRead rwms format from given folder structure. Returns a list of length nrw
\n\nExtract t0 from given .ms.dat files. Returns t0 as Obs.
\n\nIt is assumed that all boundary effects have\nsufficiently decayed at x0=xmin.\nThe data around the zero crossing of t^2
It is assumed that one measurement is performed for each config.\nIf this is not the case, the resulting idl, as well as the handling\nof r_start, r_stop and r_step is wrong and the user has to correct\nthis in the resulting observable.
\n\nRead the topologial charge based on openQCD gradient flow measurements.
\n\nRead the gradient flow coupling based on sfqcd gradient flow measurements. See 1607.06423 for details.
\n\nNote: The current implementation only works for c=0.3 and T=L. The definition of the coupling in 1607.06423 requires projection to topological charge zero which is not done within this function but has to be performed in a separate step.
\n\nReturns the projection to the topological charge sector defined by target.
\n\nConstructs reweighting factors to a specified topological sector.
\n\nRead data from files in the specified directory with the specified prefix and quark combination extension, and return a Corr
object containing the data.
**kwargs: Additional keyword arguments. The following keyword arguments are recognized:
\n\nCorr
object containing the data read from the files. In case of boudary to bulk correlators.CObs
object containing the data read from the files. In case of boudary to boundary correlators.Write DataFrame including Obs or Corr valued columns to sqlite database.
\n\nExecute SQL query on sqlite database and obtain DataFrame including Obs or Corr valued columns.
\n\nExports a pandas DataFrame containing Obs valued columns to a (gzipped) csv file.
\n\nBefore making use of pandas to_csv functionality Obs objects are serialized via the standardized\njson format of pyerrors.
\n\nImports a pandas DataFrame from a csv.(gz) file in which Obs objects are serialized as json strings.
\n\nRead sfcf files from given folder structure.
\n\nSorts a list of names of replika with searches for r
and id
in the replikum string.\nIf this search fails, a fallback method is used,\nwhere the strings are simply compared and the first diffeing numeral is used for differentiation.
Checks if list of configurations is contained in an idl
\n\nMatrix multiply all operands.
\n\nMatrix multiply both operands making use of the jackknife approximation.
\n\nWrapper for numpy.einsum
\n\nInverse of Obs or CObs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.cholesky": {"fullname": "pyerrors.linalg.cholesky", "modulename": "pyerrors.linalg", "qualname": "cholesky", "kind": "function", "doc": "Cholesky decomposition of Obs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.det": {"fullname": "pyerrors.linalg.det", "modulename": "pyerrors.linalg", "qualname": "det", "kind": "function", "doc": "Determinant of Obs valued matrices.
\n", "signature": "(x):", "funcdef": "def"}, "pyerrors.linalg.eigh": {"fullname": "pyerrors.linalg.eigh", "modulename": "pyerrors.linalg", "qualname": "eigh", "kind": "function", "doc": "Computes the eigenvalues and eigenvectors of a given hermitian matrix of Obs according to np.linalg.eigh.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.eig": {"fullname": "pyerrors.linalg.eig", "modulename": "pyerrors.linalg", "qualname": "eig", "kind": "function", "doc": "Computes the eigenvalues of a given matrix of Obs according to np.linalg.eig.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.pinv": {"fullname": "pyerrors.linalg.pinv", "modulename": "pyerrors.linalg", "qualname": "pinv", "kind": "function", "doc": "Computes the Moore-Penrose pseudoinverse of a matrix of Obs.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.linalg.svd": {"fullname": "pyerrors.linalg.svd", "modulename": "pyerrors.linalg", "qualname": "svd", "kind": "function", "doc": "Computes the singular value decomposition of a matrix of Obs.
\n", "signature": "(obs, **kwargs):", "funcdef": "def"}, "pyerrors.misc": {"fullname": "pyerrors.misc", "modulename": "pyerrors.misc", "kind": "module", "doc": "\n"}, "pyerrors.misc.print_config": {"fullname": "pyerrors.misc.print_config", "modulename": "pyerrors.misc", "qualname": "print_config", "kind": "function", "doc": "Print information about version of python, pyerrors and dependencies.
\n", "signature": "():", "funcdef": "def"}, "pyerrors.misc.errorbar": {"fullname": "pyerrors.misc.errorbar", "modulename": "pyerrors.misc", "qualname": "errorbar", "kind": "function", "doc": "pyerrors wrapper for the errorbars method of matplotlib
\n\nDump object into pickle file.
\n\nLoad object from pickle file.
\n\nGenerate an Obs object with given value, dvalue and name for test purposes
\n\nGenerate observables with given covariance and autocorrelation times.
\n\nMatrix pencil method to extract k energy levels from data
\n\nImplementation of the matrix pencil method based on\neq. (2.17) of Y. Hua, T. K. Sarkar, IEEE Trans. Acoust. 38, 814-824 (1990)
\n\nClass for a general observable.
\n\nInstances of Obs are the basic objects of a pyerrors error analysis.\nThey are initialized with a list which contains arrays of samples for\ndifferent ensembles/replica and another list of same length which contains\nthe names of the ensembles/replica. Mathematical operations can be\nperformed on instances. The result is another instance of Obs. The error of\nan instance can be computed with the gamma_method. Also contains additional\nmethods for output and visualization of the error calculation.
\n\nInitialize Obs object.
\n\nEstimate the error and related properties of the Obs.
\n\nEstimate the error and related properties of the Obs.
\n\nOutput detailed properties of the Obs.
\n\nReweight the obs with given rewighting factors.
\n\nChecks whether the observable is zero within 'sigma' standard errors.
\n\nChecks whether the observable is zero within a given tolerance.
\n\nPlot integrated autocorrelation time for each ensemble.
\n\nPlot normalized autocorrelation function time for each ensemble.
\n\nPlot replica distribution for each ensemble with more than one replicum.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.Obs.plot_history": {"fullname": "pyerrors.obs.Obs.plot_history", "modulename": "pyerrors.obs", "qualname": "Obs.plot_history", "kind": "function", "doc": "Plot derived Monte Carlo history for each ensemble
\n\nPlot piechart which shows the fractional contribution of each\nensemble to the error and returns a dictionary containing the fractions.
\n\nDump the Obs to a file 'name' of chosen format.
\n\nExport jackknife samples from the Obs
\n\nClass for a complex valued observable.
\n"}, "pyerrors.obs.CObs.__init__": {"fullname": "pyerrors.obs.CObs.__init__", "modulename": "pyerrors.obs", "qualname": "CObs.__init__", "kind": "function", "doc": "\n", "signature": "(real, imag=0.0)"}, "pyerrors.obs.CObs.gamma_method": {"fullname": "pyerrors.obs.CObs.gamma_method", "modulename": "pyerrors.obs", "qualname": "CObs.gamma_method", "kind": "function", "doc": "Executes the gamma_method for the real and the imaginary part.
\n", "signature": "(self, **kwargs):", "funcdef": "def"}, "pyerrors.obs.CObs.is_zero": {"fullname": "pyerrors.obs.CObs.is_zero", "modulename": "pyerrors.obs", "qualname": "CObs.is_zero", "kind": "function", "doc": "Checks whether both real and imaginary part are zero within machine precision.
\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.CObs.conjugate": {"fullname": "pyerrors.obs.CObs.conjugate", "modulename": "pyerrors.obs", "qualname": "CObs.conjugate", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, "pyerrors.obs.derived_observable": {"fullname": "pyerrors.obs.derived_observable", "modulename": "pyerrors.obs", "qualname": "derived_observable", "kind": "function", "doc": "Construct a derived Obs according to func(data, **kwargs) using automatic differentiation.
\n\nFor simple mathematical operations it can be practical to use anonymous\nfunctions. For the ratio of two observables one can e.g. use
\n\nnew_obs = derived_observable(lambda x: x[0] / x[1], [obs1, obs2])
\n", "signature": "(func, data, array_mode=False, **kwargs):", "funcdef": "def"}, "pyerrors.obs.reweight": {"fullname": "pyerrors.obs.reweight", "modulename": "pyerrors.obs", "qualname": "reweight", "kind": "function", "doc": "Reweight a list of observables.
\n\nCorrelate two observables.
\n\nKeep in mind to only correlate primary observables which have not been reweighted\nyet. The reweighting has to be applied after correlating the observables.\nCurrently only works if ensembles are identical (this is not strictly necessary).
\n", "signature": "(obs_a, obs_b):", "funcdef": "def"}, "pyerrors.obs.covariance": {"fullname": "pyerrors.obs.covariance", "modulename": "pyerrors.obs", "qualname": "covariance", "kind": "function", "doc": "Calculates the error covariance matrix of a set of observables.
\n\nWARNING: This function should be used with care, especially for observables with support on multiple\n ensembles with differing autocorrelations. See the notes below for details.
\n\nThe gamma method has to be applied first to all observables.
\n\nThe error covariance is defined such that it agrees with the squared standard error for two identical observables\n$$\\operatorname{cov}(a,a)=\\sum_{s=1}^N\\delta_a^s\\delta_a^s/N^2=\\Gamma_{aa}(0)/N=\\operatorname{var}(a)/N=\\sigma_a^2$$\nin the absence of autocorrelation.\nThe error covariance is estimated by calculating the correlation matrix assuming no autocorrelation and then rescaling the correlation matrix by the full errors including the previous gamma method estimate for the autocorrelation of the observables. The covariance at windowsize 0 is guaranteed to be positive semi-definite\n$$\\sum_{i,j}v_i\\Gamma_{ij}(0)v_j=\\frac{1}{N}\\sum_{s=1}^N\\sum_{i,j}v_i\\delta_i^s\\delta_j^s v_j=\\frac{1}{N}\\sum_{s=1}^N\\sum_{i}|v_i\\delta_i^s|^2\\geq 0\\,,$$ for every $v\\in\\mathbb{R}^M$, while such an identity does not hold for larger windows/lags.\nFor observables defined on a single ensemble our approximation is equivalent to assuming that the integrated autocorrelation time of an off-diagonal element is equal to the geometric mean of the integrated autocorrelation times of the corresponding diagonal elements.\n$$\\tau_{\\mathrm{int}, ij}=\\sqrt{\\tau_{\\mathrm{int}, i}\\times \\tau_{\\mathrm{int}, j}}$$\nThis construction ensures that the estimated covariance matrix is positive semi-definite (up to numerical rounding errors).
\n", "signature": "(obs, visualize=False, correlation=False, smooth=None, **kwargs):", "funcdef": "def"}, "pyerrors.obs.import_jackknife": {"fullname": "pyerrors.obs.import_jackknife", "modulename": "pyerrors.obs", "qualname": "import_jackknife", "kind": "function", "doc": "Imports jackknife samples and returns an Obs
\n\nCombine all observables in list_of_obs into one new observable
\n\nIt is not possible to combine obs which are based on the same replicum
\n", "signature": "(list_of_obs):", "funcdef": "def"}, "pyerrors.obs.cov_Obs": {"fullname": "pyerrors.obs.cov_Obs", "modulename": "pyerrors.obs", "qualname": "cov_Obs", "kind": "function", "doc": "Create an Obs based on mean(s) and a covariance matrix
\n\nFinds the root of the function func(x, d) where d is an Obs
.
func (object):\nFunction to be minimized. Any numpy functions have to use the autograd.numpy wrapper.\nExample:
\n\nimport autograd.numpy as anp\ndef root_func(x, d):\n return anp.exp(-x ** 2) - d\n
\nguess (float):\nInitial guess for the minimization.
Obs
valued root of the function.