  The interstellar medium (ISM) is a magnetised system in which transonic or
supersonic turbulence is driven by supernova explosions. This leads to the
production of intermittent, filamentary structures in the ISM gas density,
whilst the associated dynamo action also produces intermittent magnetic fields.
The traditional theory of random functions, restricted to second-order
statistical moments (or power spectra), does not adequately describe such
systems. We apply topological data analysis (TDA), sensitive to all statistical
moments and independent of the assumption of Gaussian statistics, to the gas
density fluctuations in a magnetohydrodynamic (MHD) simulation of the
multi-phase ISM. This simulation admits dynamo action, so produces physically
realistic magnetic fields. The topology of the gas distribution, with and
without magnetic fields, is quantified in terms of Betti numbers and
persistence diagrams. Like the more standard correlation analysis, TDA shows
that the ISM gas density is sensitive to the presence of magnetic fields.
However, TDA gives us important additional information that cannot be obtained
from correlation functions. In particular, the Betti numbers per correlation
cell are shown to be physically informative. Magnetic fields make the ISM more
homogeneous, reducing the abundance of both isolated gas clouds and cavities,
with a stronger effect on the cavities. Remarkably, the modification of the gas
distribution by magnetic fields is captured by the Betti numbers even in
regions more than 300 pc from the midplane, where the magnetic field is weaker
and correlation analysis fails to detect any signatures of magnetic effects.
