The accretion of planetesimals onto white dwarf atmospheres allows determination of the composition of this polluting material. This composition is usually inferred from observed pollution levels by assuming it originated from a single body. This paper instead uses a stochastic model wherein polluting planetesimals are chosen randomly from a mass distribution, finding that the single body assumption is invalid in > 20% of cases. Planetesimal compositions are modelled assuming parent bodies that differentiated into core, mantle and crust components. Atmospheric levels of Ca, Mg and Fe in the model are compared to a sample of 230 DZ white dwarfs for which such pollution is measured. A good fit is obtained when each planetesimal has its core, mantle and crust fractions chosen independently from logit-normal distributions which lead to average mass fractions of f Cru = 0.15, f Man = 0.49 and f Cor = 0.36. However, achieving this fit requires a factor 4 depletion of Mg relative to stellar material. This depletion is unlikely to originate in planetesimal formation processes, but might occur from heating while the star is on the giant branch. Alternatively the accreted material has stellar abundance, and either the inferred low Mg abundance was caused by an incorrect assumption that Mg sinks slower than Ca and Fe, or there are unmodelled biases in the observed sample. Finally, the model makes predictions for the timescale on which the observed pollutant composition varies, which should be the longer of the sinking and disc timescales, implying variability on decadal timescales for DA white dwarfs.