MaxEntResult
This module contains the MaxEntResult and the MaxEntResultData
classes. They are very much alike and share many common methods and properties.
The latter is a bare-bones version of the former that can be written to h5-files.
It contains the result of a MaxEnt calculation.
In MaxEntResult, the properties that can be read (and analyzed)
from that run are documented.
In MaxEntResultData, the plot functions for visualizing them
are documented.
- triqs_maxent.maxent_result.recursive_map(seq, func)[source]
Apply a function to all elements recursively
The list
seqis iterated and the functionfuncis applied to all elements that are not sequences.- Parameters:
- seqlist
the list that we iterate over
- funcfunction with one argument
this function is applied to each item
- class triqs_maxent.maxent_result.MaxEntResultData(matrix_structure=None, element_wise=True, complex_elements=False, use_hermiticity=True)[source]
Bases:
objectHold the result of a MaxEnt calculation
Note that some functions/attributes documented in
MaxEntResultalso apply toMaxEntResultData.- Parameters:
- matrix_structuretuple or list
the size of the matrix, as in array.shape
- element_wisebool
whether to use element-wise adding or not (i.e., whether there will be one saved scalar-valued cost function per element or only one saved matrix-valued cost function)
- complex_elementsbool
whether there are complex elements
- use_hermiticitybool
whether or not the Hermiticity of the spectral function should be used to get values of
A_out()that are were not calculated
Attributes
Get the one true spectral function \(A(\omega)\) from the default analyzer
The default analyzer
Methods
exclude(fields)Remove fields that are saved to h5
get_A_out([analyzer])Get the one true spectral function \(A(\omega)\) from the default analyzer
get_default_analyzer([analyzer])The default analyzer
include(fields)Add fields that are saved to h5
include_only(fields)Set fields that are saved to h5
plot_A([element, alpha_index])Plot a particular \(A_{\alpha}\) as a function of \(\omega\)
plot_G([element])Plot a particular \(G\) as a function of the data variable
plot_G_rec([element, alpha_index, plot_G])Plot the reconstruction \(G_{rec}\) as a function of the data variable
plot_Q([element])Plot the cost function \(Q\) as function of \(\alpha\)
plot_S([element])Plot the entropy \(S\) as function of \(\alpha\)
plot_chi2([element])Plot the misfit \(\chi^2\) as function of \(\alpha\)
plot_probability([element])Plot the probability as a function of \(\alpha\)
- include_only(fields)[source]
Set fields that are saved to h5
- Parameters:
- fieldslist of str
the fields that should be saved; by excluding some fields, unnecessary data can be skipped and thus the memory consumption lowered, but some functionality might not work
- include(fields)[source]
Add fields that are saved to h5
- Parameters:
- fieldslist of str
the fields that should be saved in addition to the ones included so far; by excluding some fields, unnecessary data can be skipped and thus the memory consumption lowered, but some functionality might not work
- exclude(fields)[source]
Remove fields that are saved to h5
- Parameters:
- fieldslist of str
the fields that should not be saved; by excluding some fields, unnecessary data can be skipped and thus the memory consumption lowered, but some functionality might not work
- get_default_analyzer(analyzer=None)[source]
The default analyzer
If the
matrix_structureis notNone, this gives back aM x Narray (for complex entriesM x N x 2) with the analyzer for that matrix element.- Parameters:
- analyzerstr
the name of the analyzer; if None, the
default_analyzer_nameis used
- property default_analyzer
The default analyzer
If the
matrix_structureis notNone, this gives back aM x Narray (for complex entriesM x N x 2) with the analyzer for that matrix element.- Parameters:
- analyzerstr
the name of the analyzer; if None, the
default_analyzer_nameis used
- get_A_out(analyzer=None)[source]
Get the one true spectral function \(A(\omega)\) from the default analyzer
- Parameters:
- analyzerstr
the name of the analyzer to use; if not given, the default analyzer (as specified by default_analyzer_name) is used
- property A_out
Get the one true spectral function \(A(\omega)\) from the default analyzer
- Parameters:
- analyzerstr
the name of the analyzer to use; if not given, the default analyzer (as specified by default_analyzer_name) is used
- plot_chi2(element=None, **kwargs)[source]
Plot the misfit \(\chi^2\) as function of \(\alpha\)
- Parameters:
- elementtuple
matrix element
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: True)
- log_ybool
whether the y-axis should be log-scaled (default: True)
- plot_S(element=None, **kwargs)[source]
Plot the entropy \(S\) as function of \(\alpha\)
- Parameters:
- elementtuple
matrix element
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: True)
- log_ybool
whether the y-axis should be log-scaled (default: False)
- plot_Q(element=None, **kwargs)[source]
Plot the cost function \(Q\) as function of \(\alpha\)
- Parameters:
- elementtuple
matrix element
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: True)
- log_ybool
whether the y-axis should be log-scaled (default: True)
- plot_A(element=None, alpha_index=0, **kwargs)[source]
Plot a particular \(A_{\alpha}\) as a function of \(\omega\)
- Parameters:
- elementtuple
matrix element
- alpha_indexint
the index of the alpha value
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: False)
- log_ybool
whether the y-axis should be log-scaled (default: False)
- plot_G(element=None, **kwargs)[source]
Plot a particular \(G\) as a function of the data variable
This plots the original \(G\) (see
G_orig()).- Parameters:
- elementtuple
matrix element
- alpha_indexint
the index of the alpha value
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: False)
- log_ybool
whether the y-axis should be log-scaled (default: False)
- plot_G_rec(element=None, alpha_index=0, plot_G=True, **kwargs)[source]
Plot the reconstruction \(G_{rec}\) as a function of the data variable
- Parameters:
- elementtuple
matrix element
- alpha_indexint
the index of the alpha value
- plot_Gbool
whether to plot the original data
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: False)
- log_ybool
whether the y-axis should be log-scaled (default: False)
- plot_probability(element=None, **kwargs)[source]
Plot the probability as a function of \(\alpha\)
- Parameters:
- elementtuple
matrix element
- labelstr
the label of the curve (for a legend)
- x_labelstr
the label of the x-axis
- y_labelstr
the label of the y-axis
- log_xbool
whether the x-axis should be log-scaled (default: False)
- log_ybool
whether the y-axis should be log-scaled (default: False)
- class triqs_maxent.maxent_result.MaxEntResult(matrix_structure=None, element_wise=True, complex_elements=False, use_hermiticity=True)[source]
Bases:
MaxEntResultDataHold the result of a MaxEnt calculation
For a description of the parameters see
MaxEntResultData.Attributes
The \(A\) (spectral function) values of the optimum
A_outGet the one true spectral function \(A(\omega)\) from the default analyzer
The Green function data (=input data)
The Green function data (=input data)
The reconstructed Green function \(G_{rec}\).
The \(H\) (hidden spectral function) values of the optimum
The \(Q\) (cost function) values of the optimum
The \(S\) (entropy) values of the optimum
The list of \(\alpha\) values
The results from the alpha analyzers
The \(\chi^2\) (misfit) values of the optimum
Get a
MaxEntResultDatadata objectThe Green function data variable (e.g. tau for \(G(\tau)\)).
default_analyzerThe default analyzer
The name of the default analyzer
The effective matrix structure including complex elements
The matrix structure
The \(\omega\) values
The probability values of the optimum
Total run time of the calculation
The run times for the individual alphas (and matrix elements)
The singular space vectors of the optimum
complex_elements
element_wise
use_hermiticity
zero_elements
Methods
add_result(cost_function[, log_probability, ...])Add the result of one particular MaxEnt optimization
analyze(analyzers[, matrix_element, ...])Analyze the data to find the one true spectral function
end_timing([matrix_element, complex_index, time])Stop timing for a particular matrix_element
exclude(fields)Remove fields that are saved to h5
get_A_out([analyzer])Get the one true spectral function \(A(\omega)\) from the default analyzer
get_default_analyzer([analyzer])The default analyzer
include(fields)Add fields that are saved to h5
include_only(fields)Set fields that are saved to h5
plot_A([element, alpha_index])Plot a particular \(A_{\alpha}\) as a function of \(\omega\)
plot_G([element])Plot a particular \(G\) as a function of the data variable
plot_G_rec([element, alpha_index, plot_G])Plot the reconstruction \(G_{rec}\) as a function of the data variable
plot_Q([element])Plot the cost function \(Q\) as function of \(\alpha\)
plot_S([element])Plot the entropy \(S\) as function of \(\alpha\)
plot_chi2([element])Plot the misfit \(\chi^2\) as function of \(\alpha\)
plot_probability([element])Plot the probability as a function of \(\alpha\)
start_timing([matrix_element, ...])Start timing for a particular matrix_element
Notes
In order to write a
MaxEntResultobject to an h5-file, useMaxEntResult.data().- add_result(cost_function, log_probability=None, matrix_element=None, complex_index=None)[source]
Add the result of one particular MaxEnt optimization
For every \(\alpha\) and possibly every matrix element (if a matrix structure is given and element_wise is True), the result of the MaxEnt optimization is collected by adding it to the result object using this method.
- Parameters:
- cost_functionCostFunction
the cost function evaluated at the optimum, which gives access to quantities like, e.g., \(\chi^2\), \(Q\), \(S\), \(A\), etc.
- log_probabilityfloat
the log of the probability of this particular solution or None (if no probability was calculated)
- matrix_elementtuple
the element that the result represents, if applicable (else: None)
- complex_indexint
if applicable, the complex index (0 for real, 1 for imaginary)
- analyze(analyzers, matrix_element=None, complex_index=None)[source]
Analyze the data to find the one true spectral function
- Parameters:
- analyzerslist of Analyzer
the data from this result object is handed over to each analyzer from this list, which will then produce a spectral function, which is saved in analyzer_results
- matrix_elementtuple
the element that shall be analyzed, if applicable (else: None)
- complex_indexint
if applicable, the complex index (0 for real, 1 for imaginary)
- property alpha
The list of \(\alpha\) values
This is also available in
MaxEntResultDataifincluded.
- property v
The singular space vectors of the optimum
For a matrix dimension
M x N, the number of alphasXand the number of singular space valuesS, this is aM x N x X x Sobject. For missing values, np.nan is used. If no matrix_structure is given, it is aX x Sobject.This is also available in
MaxEntResultDataifincluded.
- property chi2
The \(\chi^2\) (misfit) values of the optimum
For a matrix dimension
M x Nand the number of alphasX, this is aM x N x Xobject. For missing values, np.nan is used. If no matrix_structure is given, it is a list withXentries.This is also available in
MaxEntResultDataifincluded.
- property G
The Green function data (=input data)
For a matrix dimension
M x N, the number of alphasX, and the number of data-variablesT, this is aM x N x X x Tobject. For missing values, np.nan is used.In the case of an extra transformation (see
TauMaxEnt.set_cov()) this is the transformed G.This is also available in
MaxEntResultDataifincluded.
- property G_orig
The Green function data (=input data)
For a matrix dimension
M x N, the number of alphasX, and the number of data-variablesT, this is aM x N x X x Tobject. For missing values, np.nan is used.In the case of an extra transformation (see
TauMaxEnt.set_cov()) this is the original G.This is also available in
MaxEntResultDataifincluded.
- property data_variable
The Green function data variable (e.g. tau for \(G(\tau)\))
For a matrix dimension
M x N, the number of alphasX, and the number of data-variablesT, this is aM x N x X x Tobject. For missing values, np.nan is used.This is also available in
MaxEntResultDataifincluded.
- property G_rec
The reconstructed Green function \(G_{rec}\).
This is also available in
MaxEntResultDataifincluded.
- property S
The \(S\) (entropy) values of the optimum
For a matrix dimension
M x Nand the number of alphasX, this is aM x N x Xobject. For missing values, np.nan is used. If no matrix_structure is given, it is a list withXentries.This is also available in
MaxEntResultDataifincluded.
- property H
The \(H\) (hidden spectral function) values of the optimum
For a matrix dimension
M x Nand the number of alphasXand the number of omega-pointsW, this is aM x N x X x Wobject. For missing values, np.nan is used. If no matrix_structure is given, it is aX x Wobject.This is also available in
MaxEntResultDataifincluded.
- property A
The \(A\) (spectral function) values of the optimum
For a matrix dimension
M x Nand the number of alphasXand the number of omega-pointsW, this is aM x N x X x Wobject. For missing values, np.nan is used. If no matrix_structure is given, it is aX x Wobject.This is also available in
MaxEntResultDataifincluded.
- property Q
The \(Q\) (cost function) values of the optimum
For a matrix dimension
M x Nand the number of alphasX, this is aM x N x Xobject. For missing values, np.nan is used. If no matrix_structure is given, it is a list withXentries.This is also available in
MaxEntResultDataifincluded.
- property omega
The \(\omega\) values
This is also available in
MaxEntResultDataifincluded.
- property probability
The probability values of the optimum
For a matrix dimension
M x Nand the number of alphasX, this is aM x N x Xobject. For missing values, np.nan is used. If no matrix_structure is given, it is a list withXentries.This is also available in
MaxEntResultDataifincluded.
- start_timing(matrix_element=None, complex_index=None, time=None)[source]
Start timing for a particular matrix_element
- end_timing(matrix_element=None, complex_index=None, time=None)[source]
Stop timing for a particular matrix_element
- property run_time_total
Total run time of the calculation
If _start and _end were set, this yields the total run time.
This is also available in
MaxEntResultDataifincluded.
- property run_times
The run times for the individual alphas (and matrix elements)
This is also available in
MaxEntResultDataifincluded.
- property analyzer_results
The results from the alpha analyzers
For matrix-valued results, this is a list of list of … with the same matrix structure as the result.
This is also available in
MaxEntResultDataifincluded.
- property matrix_structure
The matrix structure
This is also available in
MaxEntResultDataifincluded.
- property default_analyzer_name
The name of the default analyzer
This is also available in
MaxEntResultDataifincluded.
- property effective_matrix_structure
The effective matrix structure including complex elements
This is also available in
MaxEntResultDataifincluded.
- property data
Get a
MaxEntResultDatadata objectthat can be saved to h5-files.