# Statistical analysis of ensembles of spectral functions

A theoretical framework presented in Sections I-II of [GMPPS2017] offers a way
to estimate statistical properties (averages, dispersions and two-point
correlations) of ensembles of
particular solutions. It is implemented as a
handful of functions in the `som.spectral_stats`

module.

The analysis is built around the notion of spectral integrals. Given a set of finite intervals \(\{\Delta_m\}\) centered around points \(z_m\), the spectral integrals are defined as

where kernel \(\bar K(m, z)\) is a “resolution function” localized inside \(\{\Delta_m\}\).

Function `som.spectral_stats.spectral_integral()`

evaluates \(i_m\) for
a single interval \(\Delta_m\), for all intervals induced by a
`real frequency mesh`

, or for an
arbitrary set of intervals. It supports a few kernels \(\bar K(m, z)\)
switched by the keyword argument `resolution_function`

,

`resolution_function=rectangle`

:\[\bar K(m, z) = \frac{1}{|\Delta_m|} \theta\left(\frac{|\Delta_m|}{2} - |z - z_m|\right).\]`resolution_function=lorentzian`

:\[\bar K(m, z) = \frac{1}{\pi} \frac{|\Delta_m|/2}{(z - z_m)^2 + (|\Delta_m|/2)^2}.\]`resolution_function=gaussian`

:\[\bar K(m, z) = \frac{1}{\sqrt{2\pi(|\Delta_m|/2)^2}} \exp\left(-\frac{(z - z_m)^2}{2(|\Delta_m|/2)^2}\right).\]

Having accumulated a set (ensemble) of \(J\) particular solutions, one can study statistical properties of spectral integrals \(i_m^{(j)}\) derived from them.

Function `som.spectral_stats.spectral_avg()`

computes averages over the
ensemble,

These averages can be interpreted as an estimate of the final spectrum.

While horizontal “error bars” on \(\bar{i}_m\) are simply \(|\Delta_m|/2\), the vertical ones (\(\sigma_m\)) are estimated from dispersions

Spectral dispersions are computed by `som.spectral_stats.spectral_disp()`

,
and `som.spectral_stats.spectral_corr()`

returns a full matrix of
two-points correlators