The use of the conventional opacity distribution function (ODF) to deal wit
h very many spectral lines is restricted to static media. In this paper, it
s generalization to differentially moving media is derived from the analyti
cal solution of the comoving-frame radiative transfer equation. This genera
lized ODF depends on only two parameters, on the wavelength position (as in
the static case) and in addition on a wavelength interval Delta over which
the line extinction is averaged. We present two methods for the calculatio
n of the generalized ODF: (i) in analogy to the static case, it is derived
from the mean values of the extinction coefficients over wavelength interva
ls Delta, (ii) it is calculated under the assumption that the lines follow
a Poisson point process. Both approaches comprise the conventional static c
ase as the limit of vanishing velocities, i.e. of Delta --> 0. The averages
of the extinction for all values of Delta contain the necessary informatio
n about the Doppler shifts and about the correlations between the extinctio
n at different wavelengths. The flexible statistical approximation of the l
ines by a Poisson point process as an alternative to calculating the averag
es over all Delta from a deterministic "real" spectral line list, has the a
dvantage that the number of parameters is reduced, that analytical expressi
ons allow a better insight into the effects of the lines on the radiative t
ransfer, and that the ODFs and their corresponding characteristic functions
can be calculated efficiently by (fast) Fourier transforms. Numerical exam
ples demonstrate the effects of the relevant parameters on the opacity dist
ribution functions, in particular that with increasing line density and inc
reasing Delta the ODF becomes narrower and its maximum is shifted to larger
extinction values.