A modified least-squares analysis is presented that allows reliable structu
ral parameters to be extracted from a powder diffraction pattern even in th
e presence of a substantial unmodelled impurity contribution. The algorithm
is developed within the context of Bayesian probability theory. Experiment
al points that fall above those calculated, and are thus more probably from
impurity peaks, are systematically down-weighted. This approach is illustr
ated with a two-phase example.