# Custom Observables

NetKet provides the freedom to have user’s defined Observables, which are measured during the learning procedure. Custom Observables follow the same concepts discussed for custom Hamiltonians. It is possible to add an observable specifying the relevant operators in the Observables section of the input. For the moment, this functionality is limited to lattice observables which are sums of $k$ -local operators:

where the operators $o_i$ act on an (arbitrary) subset of sites. In order to define your custom Observable, you need to specify the operators $o_i$. Notice that here the Hilbert space is derived from the definition of the Hamiltonian, thus users must specify Observables compatible with the Hamiltonian Hilbert space.

## Local Operators

The local operators $o_i$ are specified giving their matrix elements, and a list of sites on which they act. For example, to specify a single-site operator acting on site $l$, and with a local Hilbert space of two elements $n_1, n_2$, you must provide a $2 \times 2$ matrix

In general, for a $k$-local operator acting on local Hilbert spaces with $b$ quantum numbers, you must provide a $b^k \times b^k$ matrix

Parameter Possible values Description Default value
ActingOn List of list of integers The sites on which each $o_i$ acts on None
Name String Chosen name of the observable None
Operators List of floating/complex matrices For each $i$, the matrix elements of $o_i$ in the $k$-local Hilbert space None

### Example


sigmaxop=[]
sites=[]
for i in range(L):
#\sum_i sigma^x(i)
sigmaxop.append([[0,1],[1,0]])
sites.append([i])

pars['Observables']={
'Operators'      : sigmaxop,
'ActingOn'       : sites,
'Name'           : 'SigmaX',
}