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.saved(func)[source]

Cache the value of a function

triqs_maxent.maxent_result.recursive_map(seq, func)[source]

Apply a function to all elements recursively

The list seq is iterated and the function func is 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

triqs_maxent.maxent_result.recursive_dtype(seq)[source]

Get the dtype of the first item of seq.

class triqs_maxent.maxent_result.MaxEntResultData(matrix_structure=None, element_wise=True, complex_elements=False, use_hermiticity=True)[source]

Bases: object

Hold the result of a MaxEnt calculation

Note that some functions/attributes documented in MaxEntResult also apply to MaxEntResultData.

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:
A_out

Get the one true spectral function \(A(\omega)\) from the default analyzer

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_structure is not None, this gives back a M x N array (for complex entries M x N x 2) with the analyzer for that matrix element.

Parameters:
analyzerstr

the name of the analyzer; if None, the default_analyzer_name is used

property default_analyzer

The default analyzer

If the matrix_structure is not None, this gives back a M x N array (for complex entries M x N x 2) with the analyzer for that matrix element.

Parameters:
analyzerstr

the name of the analyzer; if None, the default_analyzer_name is 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: MaxEntResultData

Hold the result of a MaxEnt calculation

For a description of the parameters see MaxEntResultData.

Notes

In order to write a MaxEntResult object to an h5-file, use MaxEntResult.data().

Attributes:
A

The \(A\) (spectral function) values of the optimum

A_out

Get the one true spectral function \(A(\omega)\) from the default analyzer

G

The Green function data (=input data)

G_orig

The Green function data (=input data)

G_rec

The reconstructed Green function \(G_{rec}\).

H

The \(H\) (hidden spectral function) values of the optimum

Q

The \(Q\) (cost function) values of the optimum

S

The \(S\) (entropy) values of the optimum

alpha

The list of \(\alpha\) values

analyzer_results

The results from the alpha analyzers

chi2

The \(\chi^2\) (misfit) values of the optimum

complex_elements
data

Get a MaxEntResultData data object

data_variable

The Green function data variable (e.g.

default_analyzer

The default analyzer

default_analyzer_name

The name of the default analyzer

effective_matrix_structure

The effective matrix structure including complex elements

element_wise
matrix_structure

The matrix structure

omega

The \(\omega\) values

probability

The probability values of the optimum

run_time_total

Total run time of the calculation

run_times

The run times for the individual alphas (and matrix elements)

use_hermiticity
v

The singular space vectors of the optimum

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

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 MaxEntResultData if included.

property v

The singular space vectors of the optimum

For a matrix dimension M x N, the number of alphas X and the number of singular space values S, this is a M x N x X x S object. For missing values, np.nan is used. If no matrix_structure is given, it is a X x S object.

This is also available in MaxEntResultData if included.

property chi2

The \(\chi^2\) (misfit) values of the optimum

For a matrix dimension M x N and the number of alphas X, this is a M x N x X object. For missing values, np.nan is used. If no matrix_structure is given, it is a list with X entries.

This is also available in MaxEntResultData if included.

property G

The Green function data (=input data)

For a matrix dimension M x N, the number of alphas X, and the number of data-variables T, this is a M x N x X x T object. 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 MaxEntResultData if included.

property G_orig

The Green function data (=input data)

For a matrix dimension M x N, the number of alphas X, and the number of data-variables T, this is a M x N x X x T object. 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 MaxEntResultData if included.

property data_variable

The Green function data variable (e.g. tau for \(G(\tau)\))

For a matrix dimension M x N, the number of alphas X, and the number of data-variables T, this is a M x N x X x T object. For missing values, np.nan is used.

This is also available in MaxEntResultData if included.

property G_rec

The reconstructed Green function \(G_{rec}\).

This is also available in MaxEntResultData if included.

property S

The \(S\) (entropy) values of the optimum

For a matrix dimension M x N and the number of alphas X, this is a M x N x X object. For missing values, np.nan is used. If no matrix_structure is given, it is a list with X entries.

This is also available in MaxEntResultData if included.

property H

The \(H\) (hidden spectral function) values of the optimum

For a matrix dimension M x N and the number of alphas X and the number of omega-points W, this is a M x N x X x W object. For missing values, np.nan is used. If no matrix_structure is given, it is a X x W object.

This is also available in MaxEntResultData if included.

property A

The \(A\) (spectral function) values of the optimum

For a matrix dimension M x N and the number of alphas X and the number of omega-points W, this is a M x N x X x W object. For missing values, np.nan is used. If no matrix_structure is given, it is a X x W object.

This is also available in MaxEntResultData if included.

property Q

The \(Q\) (cost function) values of the optimum

For a matrix dimension M x N and the number of alphas X, this is a M x N x X object. For missing values, np.nan is used. If no matrix_structure is given, it is a list with X entries.

This is also available in MaxEntResultData if included.

property omega

The \(\omega\) values

This is also available in MaxEntResultData if included.

property probability

The probability values of the optimum

For a matrix dimension M x N and the number of alphas X, this is a M x N x X object. For missing values, np.nan is used. If no matrix_structure is given, it is a list with X entries.

This is also available in MaxEntResultData if included.

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 MaxEntResultData if included.

property run_times

The run times for the individual alphas (and matrix elements)

This is also available in MaxEntResultData if included.

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 MaxEntResultData if included.

property matrix_structure

The matrix structure

This is also available in MaxEntResultData if included.

property default_analyzer_name

The name of the default analyzer

This is also available in MaxEntResultData if included.

property effective_matrix_structure

The effective matrix structure including complex elements

This is also available in MaxEntResultData if included.

property data

Get a MaxEntResultData data object

that can be saved to h5-files.