# Discretisation and Volume#

Note

Some of this discussion is rather technical and may be skipped in a first read-through.

## Setup#

IFT employs stochastic processes to model distributions over function spaces, in particular Gaussian processes where denotes the covariance function. The domain of the fields, and hence , is given by a Riemannian manifold , where denotes a Riemannian metric. Fields are defined to be scalar functions on the manifold, living in the function space . Unless we find ourselves in the lucky situation that we can solve for the posterior statistics of interest analytically, we need to apply numerical methods. This is where NIFTy comes into play.

A typical setup for inference of such signals using NIFTy is shown in figure 1. We start with a continuous signal , defined in some function space over a manifold with metric . This is measured by some instrument, e.g. a telescope. The measurement produces data in an unstructured data space via a known response function and involves noise with known covariance matrix . In the case of additive noise, the result of the measurement is given by

## Discretisation and index notation#

To compute anything numerically, we first need to represent the problem in finite dimensions. As for stochastic processes, several discretisations of like collocation methods, expansion into orthogonal polynomials, etc. can be used (see 1, 2 for an overview and further information about their reliability). In particular, NIFTy uses the midpoint method as reviewed in section 2.1 of 1 and Fourier expansion.

Without going into the details, discretisation methods basically introduce a finite set of basis functions , where denotes a generic index set with being the chosen discretisation dimension. Any Riemannian manifold is equipped with a canonical scalar product given by

Projection to the finite basis is then given by

where the Einstein summation convention is assumed and we defined the volume metric

along with its inverse, , satisfying .

Obviously, the basis needs to be chosen s.th. the volume metric is invertible, otherwise we run into trouble. Volume factors are encoded into the . For specific choices of the basis , e.g. indicator functions in the case of a pixelation, the entries of are indeed just the volumes of the elements. Lowering and raising indices works with and just as usual.

After projection, any function is represented by its approximation , where

which defines an embedding .

**Changes of base** are performed by reapproximating the in terms of another basis :

which in general implies additional loss of information unless the two bases are compatible, i.e. encode the same information. The latter is e.g. true for regular collocation grids on tori and the associated cropped Fourier series. The discrete Fourier transform then maps between those bases without loss of information.

**Discretisation of operators** works in the same way by expansion.
For illustration purposes, let be a (not necessarily linear) operator.
The result of its action on functions is known and may be expanded in , i.e.

where the domain of the operator may be restricted to the image of the embedding given above. Integrals can now be written as

where the appearance of the volume metric can be hidden by lowering the first index of the operator,

Hence, the volume metric need not be carried along if the operators are defined in this fashion right from the start. Linear operators mapping several functions to another function are completely specified by their action on a given basis, and we define

If is a (linear) integral operator defined by a kernel , its components due to are given by

## Resolution and self-consistency#

Looking at figure 1, we see that the there are two response operators: On the one hand, there is the actual response of the instrument used for measurement, mapping the actual signal to data. On the other hand, there is a discretised response , mapping from the discretised space to data. Apparently, the discretisation and the discretised response need to satisfy a self-consistency equation, given by

An obvious corollary is that different discretisations with resulting discretised responses will need to satisfy

NIFTy is implemented such that in order to change resolution, only the line of code defining the space needs to be altered. It automatically takes care of dependent structures like volume factors, discretised operators and responses. A visualisation of this can be seen in figure 2, which displays the MAP inference of a signal at various resolutions.

## Implementation in NIFTy#

Most codes in NIFTy will contain the description of a measurement process or, more generally, a log-likelihood. This log-likelihood is necessarily a map from the quantity of interest (a field) to a real number. The log-likelihood has to be unitless because it is a log-probability and should not scale with resolution. Often, log-likelihoods contain integrals over the quantity of interest , which have to be discretized, e.g. by a sum

Here the domain of the integral is the disjoint union over smaller , e.g. the pixels of the space, and is the discretised field value on the -th pixel.
This introduces the weighting , also called the volume factor, a property of the space.
NIFTy aids you in constructing your own log-likelihood by providing methods like `weight()`

, which weights all pixels of a field with their corresponding volume.
An integral over a `Field`

`s`

can be performed by calling `s.weight(1).sum()`

, which is equivalent to `s.integrate()`

.
Volume factors are also applied automatically in the following places:

`FFTOperator`

as well as all other harmonic operators. Here the zero mode of the transformed field is the integral over the original field, thus the whole field is weighted once.Some response operators, such as the

`LOSResponse`

. In this operator a line integral is discretised, so a 1-dimensional volume factor is applied.In

`CorrelatedField`

as well as`MfCorrelatedField`

. Both describe fields with a smooth, a priori unknown correlation structure specified by a power spectrum. The field is multiplied by the square root of the total volume of it domain’s harmonic counterpart. This ensures that the same power spectrum can be used regardless of the chosen resolution, provided the total volume of the space remains the same. It also guarantees that the power spectra in NIFTy behave according to their definition, i.e. the power of a mode is the expectation value of that mode squared, divided by the volume of its space .

Note that in contrast to some older versions of NIFTy, the dot product `s.vdot(t)`

of fields does **not** apply a volume factor, but instead just sums over the field components,

where the bar denotes complex conjugation.
This dot product is **not** invariant under changes in resolution, as then the number of discretised field components increases.
Upper index components like , however, are designed **not** to scale with the volume.

One solution to obtain a resolution independent quantity is to make one of the two factors extensive while the other stays intensive. This is more explicit when intensive quantities are denoted by an upper index and extensive quantities by a lower index,

where we used Einstein sum convention. Here, the volume metric is incorporated by lowering one index, i.e. . When building statistical models, all indices will end up matching this upper-lower convention automatically, e.g. for a Gaussian log-likelihood we have

with the covariance defined by

Consequently, the inverse covariance operator will automatically have lower indices,

ensuring that the whole log-likelihood expression does not scale with resolution.
**This upper-lower index convention is not coded into NIFTy**, in order to not reduce user freedom.
One should however have this in mind when constructing log-likelihoods in order to ensure resolution independence.

## Harmonic Transform Convention#

In NIFTy the convention for the harmonic transformations is set by requiring the zero mode of the transformed field to be the integral over the original field. This choice is convenient for the Fourier transformation and used throughout the literature. Note that for the spherical harmonics this convention is only rarely used and might result in unexpected factors in the transformed field.

To be specific, for the spherical harmonics transformation this means that a monopole of unit amplitude in position-space which is transformed to the spherical harmonics domain and back to the original position space via the adjoint transformation will have a non-unit amplitude afterwards. The factor between the input field and the twice transformed field is . In comparison to the convention used in HEALPix, this corresponds to dividing the output of the HEALPix transformed field by in each transformation.

Depending on the use-case, additional volume factors must be accounted for. This is especially true if one wants to define the inverse transformation. Note that the convention for the harmonic transformations used in NIFTy results in non-unitary operators.