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
NormalEntropyshould be used, for off-diagonals thePlusMinusEntropy.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_vand aPlusMinusH_of_v.the definition of the parametrization of \(A(H)\); for normal calculations the
IdentityA_of_Htakes care of the factor \(\Delta\omega\) in non-uniform \(\omega\) meshes. For preblur calculations (see Continuation of metallic solutions using preblur), thePreblurA_of_Hadditionally blurs the hidden image \(H\) to get the spectral function \(A\).
- class triqs_maxent.functions.CachedFunction[source]
Bases:
GenericFunctionA 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.
Methods
__call__(x)Call self as a function.
parameter_change()Notify the function that parameters have changed
- class triqs_maxent.functions.DoublyDerivableFunction(**kwargs)[source]
Bases:
CachedFunctionTemplate for a double derivable function
This function has the methods
f,danddd, representing the function values and its two derivatives.Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(x)first derivative
dd(x)second derivative
f(x)function value
parameter_change()Notify the function that parameters have changed
- check_derivatives(around, renorm=False, prec=1e-08)[source]
check derivatives using numerical derivation
- Parameters:
- aroundarray
the value that should be inserted for
xin 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)
- class triqs_maxent.functions.InvertibleFunction(**kwargs)[source]
Bases:
CachedFunctionTemplate for an invertible function
This function has the methods
fandinv, representing the function values and the inverse functionMethods
__call__(x)Call self as a function.
check_inv(y[, prec])check whether inv is really the inverse of f
f(x)function value
inv(y)inverse function value
parameter_change()Notify the function that parameters have changed
- class triqs_maxent.functions.NullFunction(**kwargs)[source]
Bases:
DoublyDerivableFunctionA constant function that is zero
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(x)first derivative
dd(x)second derivative
f(x)function value
parameter_change()Notify the function that parameters have changed
- class triqs_maxent.functions.Chi2(K=None, G=None, err=None)[source]
Bases:
DoublyDerivableFunctionA function giving the least squares
- Parameters:
- K
Kernel the kernel to use
- Garray
the Green function data
- errarray
the error of the Green function data (must have the same length as G)
- K
- Attributes:
- G
- K
- axes_preference
- data_variable
- err
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(x)first derivative
dd(x)second derivative
f(x)function value
parameter_change()Notify the function that parameters have changed
get_G
get_K
get_data_variable
get_err
get_omega
set_G
set_K
set_data_variable
set_err
set_omega
- class triqs_maxent.functions.NormalChi2(K=None, G=None, err=None)[source]
Bases:
Chi2A 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:
- K
Kernel the kernel to use
- Garray
the Green function data
- errarray
the error of the Green function data (must have the same length as G)
- K
- Attributes:
- G
- K
- axes_preference
- data_variable
- err
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
Notify that the parameters (either
Korerr) have changedget_G
get_K
get_data_variable
get_err
get_omega
set_G
set_K
set_data_variable
set_err
set_omega
- class triqs_maxent.functions.ComplexChi2(K=None, G=None, err=None)[source]
Bases:
Chi2A 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:
- K
Kernel the kernel to use
- Garray
the Green function data
- errarray
the error of the Green function data (must have the same length as G)
- K
- Attributes:
- G
- K
- axes_preference
- data_variable
- err
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
Notify that the parameters (either
Korerr) have changedget_G
get_K
get_data_variable
get_err
get_omega
set_G
set_K
set_data_variable
set_err
set_omega
- class triqs_maxent.functions.Entropy(D=None)[source]
Bases:
DoublyDerivableFunctionA function giving an entropy term for regularization
- Parameters:
- DDefaultModel
the default model
- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(x)first derivative
dd(x)second derivative
f(x)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.NormalEntropy(D=None)[source]
Bases:
EntropyThe 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
- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.PlusMinusEntropy(D=None)[source]
Bases:
NormalEntropyThe 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
- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.ComplexPlusMinusEntropy(D=None)[source]
Bases:
PlusMinusEntropyThe 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
- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.AbsoluteEntropy(D=None)[source]
Bases:
EntropyThe entropy with
|A|Warning
This entropy is not convex!
- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.ShiftedAbsoluteEntropy(D=None)[source]
Bases:
EntropyThe entropy with
|A|+D- Attributes:
- D
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
d(A)first derivative
dd(A)second derivative
f(A)function value
parameter_change()Notify the function that parameters have changed
get_D
get_omega
set_D
set_omega
- class triqs_maxent.functions.GenericH_of_v(D=None, K=None)[source]
Bases:
DoublyDerivableFunction,InvertibleFunctionA function giving the parametrization \(H(v)\)
- Parameters:
- DDefaultModel
the default model to use
- K
Kernel the kernel to use
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(x)first derivative
dd(x)second derivative
f(x)function value
inv(y)inverse function value
parameter_change()Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.NormalH_of_v(D=None, K=None)[source]
Bases:
GenericH_of_vBryan’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
- K
Kernel the kernel to use
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(v)first derivative
dd(v)second derivative
f(v)function value
inv(A)inverse function value
parameter_change()Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.PlusMinusH_of_v(D=None, K=None)[source]
Bases:
GenericH_of_vPlus/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
- K
Kernel the kernel to use
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(v)first derivative
dd(v)second derivative
f(v)function value
inv(A)inverse function value
parameter_change()Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.ComplexPlusMinusH_of_v(D=None, K=None)[source]
Bases:
PlusMinusH_of_vComplex 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
- K
Kernel the kernel to use
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(v)first derivative
dd(v)second derivative
f(v)function value
inv(A)inverse function value
parameter_change()Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.NoExpH_of_v(D=None, K=None)[source]
Bases:
GenericH_of_vParametrization H(v) without the exponential
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(v)first derivative
dd(v)second derivative
f(v)function value
inv(A)inverse function value
parameter_change()Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.IdentityH_of_v(D=None, K=None)[source]
Bases:
GenericH_of_vParametrization H(v)=v
- Attributes:
- D
- K
- axes_preference
- input_size
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(v)first derivative
dd(v)second derivative
f(v)function value
inv(A)inverse function value
Notify the function that parameters have changed
get_D
get_K
get_omega
set_D
set_K
set_omega
- class triqs_maxent.functions.GenericA_of_H(**kwargs)[source]
Bases:
DoublyDerivableFunction,InvertibleFunctionA parametrization \(A(H)\)
- Attributes:
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(x)first derivative
dd(x)second derivative
f(x)function value
inv(y)inverse function value
parameter_change()Notify the function that parameters have changed
get_omega
set_omega
- class triqs_maxent.functions.IdentityA_of_H(omega)[source]
Bases:
GenericA_of_HParametrization A(H)=H
For non-uniform omega meshes, this takes care of the \(\Delta \omega\). Use this whenever you don’t use the
PreblurKernel- Attributes:
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(H)first derivative
dd(H)second derivative
f(H)function value
inv(A)inverse function value
parameter_change()Notify the function that parameters have changed
get_omega
set_omega
- class triqs_maxent.functions.PreblurA_of_H(b, omega)[source]
Bases:
GenericA_of_HA_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
- Attributes:
- b
- omega
Methods
__call__(x)Call self as a function.
check_d(around[, renorm, prec])check first derivative
check_dd(around[, renorm, prec])check second derivative
check_derivatives(around[, renorm, prec])check derivatives using numerical derivation
check_inv(y[, prec])check whether inv is really the inverse of f
d(H)first derivative
dd(H)second derivative
f(H)function value
inv(A)inverse function value
Notify the function that parameters have changed
get_b
get_omega
set_b
set_omega