Functions

This file defines a bunch of functions that represent physical functions in the MaxEnt formalism.

The base classes for all these are DoublyDerivableFunction and/or InvertibleFunction.

The most important functions defined are

  • the definition of the \(\chi^2\), which comes as NormalChi2.

  • the definition of the entropy; for diagonal elements of Green functions the NormalEntropy should be used, for off-diagonals the PlusMinusEntropy.

  • the definition of the parametrization of \(H(v)\) in singular space (which maps a vector \(v\) in singular space to a spectral function \(H\)); here, again we have a NormalH_of_v and a PlusMinusH_of_v.

  • the definition of the parametrization of \(A(H)\); for normal calculations the IdentityA_of_H takes care of the factor \(\Delta\omega\) in non-uniform \(\omega\) meshes. For preblur calculations (see Continuation of metallic solutions using preblur), the PreblurA_of_H additionally blurs the hidden image \(H\) to get the spectral function \(A\).

triqs_maxent.functions.cached(func)[source]

A descriptor for cached functions

class triqs_maxent.functions.CachedFunction[source]

Bases: GenericFunction

A function that remembers its values

The general way to use the functions that are cached, which here are all the functions derived from GenericFunction, is to supply the argument to the function class and then get either the function value as .f(), the derivative as .d(), or the second derivative as .dd(). Note that it is advisable to supply the argument once (e.g. cf(x)) and evaluate everything afterwards as then the results are being cached.

Note that just the reference of the supplied argument is stored, i.e. if you change it there might be inconsistent results.

class triqs_maxent.functions.DoublyDerivableFunction(**kwargs)[source]

Bases: CachedFunction

Template for a double derivable function

This function has the methods f, d and dd, representing the function values and its two derivatives.

f(x)[source]

function value

d(x)[source]

first derivative

dd(x)[source]

second derivative

check_derivatives(around, renorm=False, prec=1e-08)[source]

check derivatives using numerical derivation

Parameters:
aroundarray

the value that should be inserted for x in the functions

renormbool or float

if bool: if False, do not renormalize, if True: renormalize by the function value; if float, renormalize by the value of the float; this allows to get some kind of relative error

precfloat

the precision of the check, i.e. if the error is larger than prec, a warning will be issued

Returns:
successbool

whether the test passed (True) or not (False)

check_d(around, renorm=False, prec=1e-08)[source]

check first derivative

see check_derivatives()

check_dd(around, renorm=False, prec=1e-08)[source]

check second derivative

see check_derivatives()

class triqs_maxent.functions.InvertibleFunction(**kwargs)[source]

Bases: CachedFunction

Template for an invertible function

This function has the methods f and inv, representing the function values and the inverse function

f(x)[source]

function value

inv(y)[source]

inverse function value

check_inv(y, prec=1e-08)[source]

check whether inv is really the inverse of f

class triqs_maxent.functions.NullFunction(**kwargs)[source]

Bases: DoublyDerivableFunction

A constant function that is zero

f(x)[source]

function value

d(x)[source]

first derivative

dd(x)[source]

second derivative

class triqs_maxent.functions.Chi2(K=None, G=None, err=None)[source]

Bases: DoublyDerivableFunction

A function giving the least squares

Parameters:
KKernel

the kernel to use

Garray

the Green function data

errarray

the error of the Green function data (must have the same length as G)

class triqs_maxent.functions.NormalChi2(K=None, G=None, err=None)[source]

Bases: Chi2

A function giving the usual least squares

This is calculated as

\[\chi^2 = \sum_i \frac{(G_i - \sum_j K_{ij} H_j)^2}{\sigma_i^2}\]

Note that \(H = A\Delta\omega\) (in the usual case, see Continuation of metallic solutions using preblur for a different definition).

Parameters:
KKernel

the kernel to use

Garray

the Green function data

errarray

the error of the Green function data (must have the same length as G)

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

parameter_change()[source]

Notify that the parameters (either K or err) have changed

class triqs_maxent.functions.ComplexChi2(K=None, G=None, err=None)[source]

Bases: Chi2

A function giving the usual least squares

This is calculated as

\[\chi^2 = \sum_i \frac{|G_i - \sum_j K_{ij} H_j|^2}{\sigma_i^2}\]

Note that \(H = A\Delta\omega\) (in the usual case, see Continuation of metallic solutions using preblur for a different definition).

Parameters:
KKernel

the kernel to use

Garray

the Green function data

errarray

the error of the Green function data (must have the same length as G)

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

parameter_change()[source]

Notify that the parameters (either K or err) have changed

class triqs_maxent.functions.Entropy(D=None)[source]

Bases: DoublyDerivableFunction

A function giving an entropy term for regularization

Parameters:
DDefaultModel

the default model

class triqs_maxent.functions.NormalEntropy(D=None)[source]

Bases: Entropy

The usual entropy

This calculates the entropy as

\[S = \sum_i (H_i - D_i - H_i \log(H_i/D_i)).\]

Note that \(H = A\Delta\omega\) (in the usual case, see Continuation of metallic solutions using preblur for a different definition). Also, the default model usually includes the \(\Delta\omega\).

Parameters:
DDefaultModel

the default model

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

class triqs_maxent.functions.PlusMinusEntropy(D=None)[source]

Bases: NormalEntropy

The Plus-Minus entropy

This calculates the entropy as

\[S = S_{normal}(H^+) + S_{normal}(H^-),\]

where \(S_{normal}\) is the NormalEntropy. We have \(H = H^+ - H^-\).

Note that \(H = A\Delta\omega\) (in the usual case, see Continuation of metallic solutions using preblur for a different definition). Also, the default model usually includes the \(\Delta\omega\).

Parameters:
DDefaultModel

the default model

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

class triqs_maxent.functions.ComplexPlusMinusEntropy(D=None)[source]

Bases: PlusMinusEntropy

The Plus-Minus entropy for complex A

This calculates the entropy as

\[S = S_{plusminus}(\mathrm{Re}\, H) + S_{plusminus}(\mathrm{Im}\, H),\]

where \(S_{plusminus}\) is the PlusMinusEntropy.

Note that \(H = A\Delta\omega\) (in the usual case, see Continuation of metallic solutions using preblur for a different definition). Also, the default model usually includes the \(\Delta\omega\).

Parameters:
DDefaultModel

the default model

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

class triqs_maxent.functions.AbsoluteEntropy(D=None)[source]

Bases: Entropy

The entropy with |A|

Warning

This entropy is not convex!

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

class triqs_maxent.functions.ShiftedAbsoluteEntropy(D=None)[source]

Bases: Entropy

The entropy with |A|+D

f(A)[source]

function value

d(A)[source]

first derivative

dd(A)[source]

second derivative

class triqs_maxent.functions.GenericH_of_v(D=None, K=None)[source]

Bases: DoublyDerivableFunction, InvertibleFunction

A function giving the parametrization \(H(v)\)

Parameters:
DDefaultModel

the default model to use

KKernel

the kernel to use

class triqs_maxent.functions.NormalH_of_v(D=None, K=None)[source]

Bases: GenericH_of_v

Bryan’s parametrization H(v)

This parametrization uses

\[H(v) = D \exp(Vv),\]

where \(V\) is the matrix of the right-singular vectors of the kernel.

Parameters:
DDefaultModel

the default model to use

KKernel

the kernel to use

f(v)[source]

function value

d(v)[source]

first derivative

dd(v)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.PlusMinusH_of_v(D=None, K=None)[source]

Bases: GenericH_of_v

Plus/minus parametrization H(v)

This should be used with the PlusMinusEntropy. The parametrization is

\[H(v) = D (e^{Vv} - e^{-Vv})\]

where \(V\) is the matrix of the right-singular vectors of the kernel.

Parameters:
DDefaultModel

the default model to use

KKernel

the kernel to use

f(v)[source]

function value

d(v)[source]

first derivative

dd(v)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.ComplexPlusMinusH_of_v(D=None, K=None)[source]

Bases: PlusMinusH_of_v

Complex plus/minus parametrization H(v)

This should be used with the ComplexPlusMinusEntropy. The parametrization is

\[H(v) = D (e^{Vv} - e^{-Vv}) TODO\]

where \(V\) is the matrix of the right-singular vectors of the kernel.

Parameters:
DDefaultModel

the default model to use

KKernel

the kernel to use

f(v)[source]

function value

d(v)[source]

first derivative

dd(v)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.NoExpH_of_v(D=None, K=None)[source]

Bases: GenericH_of_v

Parametrization H(v) without the exponential

f(v)[source]

function value

d(v)[source]

first derivative

dd(v)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.IdentityH_of_v(D=None, K=None)[source]

Bases: GenericH_of_v

Parametrization H(v)=v

parameter_change()[source]

Notify the function that parameters have changed

This allows to reprocess certain values.

f(v)[source]

function value

d(v)[source]

first derivative

dd(v)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.GenericA_of_H(**kwargs)[source]

Bases: DoublyDerivableFunction, InvertibleFunction

A parametrization \(A(H)\)

class triqs_maxent.functions.IdentityA_of_H(omega)[source]

Bases: GenericA_of_H

Parametrization A(H)=H

For non-uniform omega meshes, this takes care of the \(\Delta \omega\). Use this whenever you don’t use the PreblurKernel

f(H)[source]

function value

d(H)[source]

first derivative

dd(H)[source]

second derivative

inv(A)[source]

inverse function value

class triqs_maxent.functions.PreblurA_of_H(b, omega)[source]

Bases: GenericA_of_H

A_of_H using preblur

With preblur, we have \(A(H) = BH\) (up to a \(\Delta\omega\) for non-uniform omega meshes).

Use this whenever you use the PreblurKernel.

Parameters:
bfloat

blur parameter (width of Gaussian)

omegaarray

the omega mesh used for H_of_v

parameter_change()[source]

Notify the function that parameters have changed

This allows to reprocess certain values.

f(H)[source]

function value

d(H)[source]

first derivative

dd(H)[source]

second derivative

inv(A)[source]

inverse function value