  We recently derived analytical expressions for the pairwise (auto)correlation
functions (CFs) between modular layers (MLs) in close-packed structures (CPSs)
for the wide class of stacking processes describable as hidden Markov models
(HMMs) [Riechers \etal, (2014), Acta Crystallogr.~A, XX 000-000]. We now use
these results to calculate diffraction patterns (DPs) directly from HMMs,
discovering that the relationship between the HMMs and DPs is both simple and
fundamental in nature. We show that in the limit of large crystals, the DP is a
function of parameters that specify the HMM. We give three elementary but
important examples that demonstrate this result, deriving expressions for the
DP of CPSs stacked (i) independently, (ii) as infinite-Markov-order randomly
faulted 2H and 3C stacking structures over the entire range of growth and
deformation faulting probabilities, and (iii) as a HMM that models
Shockley-Frank stacking faults in 6H-SiC. While applied here to planar faulting
in CPSs, extending the methods and results to planar disorder in other layered
materials is straightforward. In this way, we effectively solve the broad
problem of calculating a DP---either analytically or numerically---for any
stacking structure---ordered or disordered---where the stacking process can be
expressed as a HMM.
