  A dark photon may kinetically mix with the Standard Model photon, leading to
observable cosmological signatures. The mixing is resonantly enhanced when the
dark photon mass matches the primordial plasma frequency, which depends
sensitively on the underlying spatial distribution of electrons. Crucially,
inhomogeneities in this distribution can have a significant impact on the
nature of resonant conversions. We develop and describe, for the first time, a
general analytic formalism to treat resonant oscillations in the presence of
inhomogeneities. Our formalism follows from the theory of level crossings of
random fields and only requires knowledge of the one-point probability
distribution function (PDF) of the underlying electron number density
fluctuations. We validate our formalism using simulations and illustrate the
photon-to-dark photon conversion probability for several different choices of
PDFs that are used to characterize the low-redshift Universe.
