Cost Functions

class triqs_maxent.cost_functions.cost_function.CostFunction(chi2=None, S=None, H_of_v=None, A_of_H=None, chi2_factor=1.0)[source]

Bases: DoublyDerivableFunction

The base class for the function to be minimized

Parameters:
chi2Chi2

the expression for chi2 (e.g. NormalChi2)

SEntropy

the expression for S (e.g. NormalEntropy)

H_of_vH_of_v

the expression for \(H(v)\) (e.g. NormalH_of_v)

A_of_HA_of_H

the expression for \(A(H)\) (e.g. IdentityA_of_H)

chi2_factorfloat

an additional factor for the \(\chi^2\) term of the cost function (default: 1.0)

Attributes:
A_of_H
D
G
G_orig
H_of_v
K
S
chi2
data_variable
err
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(v)

Calculate the derivative of the function to be minimized

dd(v)

Calculate the 2nd derivative of the function to be minimized

f(v)

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

get_data_variable()

parameter_change()

Notify the function that parameters have changed

set_alpha(alpha)

Set the hyper-parameter.

get_A_of_H

get_D

get_G

get_H_of_v

get_K

get_S

get_chi2

get_err

get_omega

set_A_of_H

set_D

set_G

set_H_of_v

set_K

set_S

set_chi2

set_data_variable

set_err

set_omega

set_alpha(alpha)[source]

Set the hyper-parameter.

f(v)[source]

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

Parameters:
varray

vector in singular space giving the solution; if None, the last supplied value should be reused

d(v)[source]

Calculate the derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution if None, the last supplied value should be reused

dd(v)[source]

Calculate the 2nd derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution if None, the last supplied value should be reused

parameter_change()[source]

Notify the function that parameters have changed

This allows to reprocess certain values.

MaxEnt cost function

class triqs_maxent.cost_functions.maxent_cost_function.MaxEntCostFunction(d_dv=False, dA_projection=2, **kwargs)[source]

Bases: CostFunction

The usual MaxEnt cost function

The expression for the cost function is

\[Q_\alpha(v) = \frac12 \chi^2(H(v)) \eta - \alpha S(H(v)),\]

where \(\eta\) is an additional factor for the \(\chi^2\) term, which can be given as chi2_factor (default: 1.0).

This function implements the usual derivatives d and dd, where by default (i.e., with d_dv = False) d is \(\frac{\partial Q_\alpha}{\partial H}\) and dd is \(\frac{\partial^2 Q_\alpha}{\partial H \partial v}\). If dA_projection>0, the derivatives are projected into singular space; either by multiplying from the left by \(V^\dagger\) (i.e., the matrix with the right singular vectors, if dA_projection=1) or by \(\partial H/\partial v\) (if dA_projection=2).

If d_dv = True, we have d giving \(\frac{\partial Q_\alpha}{\partial v}\); dd is again the derivative of d with respect to v.

This cost function should be used for general \(\chi^2\) and \(S\). If you use the normal values, it is possible to use the BryanCostFunction instead.

Parameters:
d_dvbool

see explanation above

dA_projectionint (0, 1, 2)

see explanation above; it is ignored if d_dv = True

**kwargs

gets passed to CostFunction

Attributes:
A_of_H
D
G
G_orig
H_of_v
K
S
chi2
data_variable
err
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(v)

Calculate the derivative of the function to be minimized

dH(v)

Calculate the derivative of the function with respect to H

dd(v)

Calculate the 2nd derivative of the function to be minimized

ddH(v)

Calculate the 2nd derivative of the function with respect to H

f(v)

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

get_data_variable()

parameter_change()

Notify the function that parameters have changed

set_alpha(alpha)

Set the hyper-parameter.

get_A_of_H

get_D

get_G

get_H_of_v

get_K

get_S

get_chi2

get_err

get_omega

set_A_of_H

set_D

set_G

set_H_of_v

set_K

set_S

set_chi2

set_data_variable

set_err

set_omega

f(v)[source]

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

Parameters:
varray

vector in singular space giving the solution

dH(v)[source]

Calculate the derivative of the function with respect to H

d(v)[source]

Calculate the derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution

ddH(v)[source]

Calculate the 2nd derivative of the function with respect to H

dd(v)[source]

Calculate the 2nd derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution

Bryan Cost Function

class triqs_maxent.cost_functions.bryan_cost_function.BryanCostFunction(chi2_factor=1.0)[source]

Bases: CostFunction

The usual MaxEnt cost function

This cost function contains some simplifications that are only valid if the normal \(\chi^2\) and \(S\) are used, i.e., it does only work for diagonal entries of the spectral function. For a general cost function, use MaxEntCostFunction.

The expression for the cost function is

\[Q_\alpha(v) = \frac12 \chi^2(H(v)) \eta - \alpha S(H(v)),\]

where \(\eta\) is an additional factor for the \(\chi^2\) term, which can be given as chi2_factor (default: 1.0).

The derivatives d and dd do not actually give the derivatives of the cost function, but a simplified version that is obtained when multiplying from the left by \(V^\dagger\).

Parameters:
chi2_factorfloat

an additional factor for the \(\chi^2\) term of the cost function (default: 1.0)

Attributes:
A_of_H
D
G
G_orig
H_of_v
K
S
chi2
data_variable
err
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(v)

Calculate the derivative of the function to be minimized

dH(v)

Calculate the derivative of the function with respect to H

dd(v)

Calculate the 2nd derivative of the function to be minimized

ddH(v)

Calculate the 2nd derivative of the function with respect to H

f(v)

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

get_data_variable()

parameter_change()

Notify the function that parameters have changed

set_alpha(alpha)

Set the hyper-parameter.

get_A_of_H

get_D

get_G

get_H_of_v

get_K

get_S

get_chi2

get_err

get_omega

set_A_of_H

set_D

set_G

set_H_of_v

set_K

set_S

set_chi2

set_data_variable

set_err

set_omega

f(v)[source]

Calculate the function to be minimized, \(Q_{\alpha}(v)\).

Parameters:
varray

vector in singular space giving the solution

dH(v)[source]

Calculate the derivative of the function with respect to H

d(v)[source]

Calculate the derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution

ddH(v)[source]

Calculate the 2nd derivative of the function with respect to H

dd(v)[source]

Calculate the 2nd derivative of the function to be minimized

Parameters:
varray

vector in singular space giving the solution