- This paper reports on the Monte Carlo simulation of in vivo x-ray fluorescence (XRF) measurements. Our model is an improvement on previously reported simulations in that it relies on a theoretical basis for modelling Compton momentum broadening as well as detector efficiency. Furthermore, this model is an accurate simulation of experimentally detected spectra when comparisons are made in absolute counts; preceding models have generally only achieved agreement with spectra normalized to unit area. Our code is sufficiently flexible to be applied to the investigation of numerous source-excited in vivo XRF systems. Thus far the simulation has been applied to the modelling of two different systems. The first application was the investigation of various aspects of a new in vivo XRF system, the measurement of uranium in bone with 57Co in a backscatter (approximately 180 degrees) geometry. The Monte Carlo simulation was critical in assessing the potential of applying XRF to the measurement of uranium in bone. Currently the Monte Carlo code is being used to evaluate a potential means of simplifying an established in vivo XRF system, the measurement of lead in bone with 57Co in a 90 degrees geometry. The results from these simulations may demonstrate that calibration procedures can be significantly simplified and subject dose may be reduced. As well as providing an excellent tool for optimizing designs of new systems and improving existing techniques, this model can be used in the investigation of the dosimetry of various XRF systems. Our simulation allows a detailed understanding of the numerous processes involved when heavy metal concentrations are measured in vivo with XRF.