  We study, theoretically and experimentally, disorder-induced resonances in
randomly-layered samples,and develop an algorithm for the detection and
characterization of the effective cavities that give rise to these resonances.
This algorithm enables us to find the eigen-frequencies and pinpoint the
locations of the resonant cavities that appear in individual realizations of
random samples, for arbitrary distributions of the widths and refractive
indices of the layers. Each cavity is formed in a region whose size is a few
localization lengths. Its eigen-frequency is independent of the location inside
the sample, and does not change if the total length of the sample is increased
by, for example, adding more scatterers on the sides. We show that the total
number of cavities, $N_{\mathrm{cav}}$, and resonances, $N_{\mathrm{res}}$, per
unit frequency interval is uniquely determined by the size of the disordered
system and is independent of the strength of the disorder. In an active,
amplifying medium, part of the cavities may host lasing modes whose number is
less than $N_{\mathrm{res}}$. The ensemble of lasing cavities behaves as
distributed feedback lasers, provided that the gain of the medium exceeds the
lasing threshold, which is specific for each cavity. We present the results of
experiments carried out with single-mode optical fibers with gain and
randomly-located resonant Bragg reflectors (periodic gratings). When the fiber
was illuminated by a pumping laser with an intensity high enough to overcome
the lasing threshold, the resonances revealed themselves by peaks in the
emission spectrum. Our experimental results are in a good agreement with the
theory presented here.
