Energy‐dispersive X‐ray fluorescence spectroscopy has been effectively applied to detect heavy metals in soil because of its fast detection speed, low cost, and high accuracy. However, overlapping peaks appear in the detection of some heavy metals, such as Pb and As, resulting in significant errors in the detection. Therefore, it is impossible to accurately predict the content of heavy metals in soil. To solve this problem, a Gaussian mixture statistical model (GMSM) is applied based on physical characteristics randomly formed by X‐rays combined with statistical ideas. Subsequently, when estimating the parameters of the GMSM, performing particle swarm optimization (PSO) causes the parameters to fall into the local optima easily. Chaos theory is introduced to the PSO algorithm to promote its weight update strategy, and the chaotic PSO (CPSO) with an anti‐premature mechanism is proposed to achieve global convergence. When using CPSO‐GMSM to analyze the overlapping peaks, the relative error compared with the actual single metal sample is less than 0.0693, and the error compared with the actual characteristic peak position is less than 0.0133. The overlapping peaks are corrected effectively, providing a foundation for the accurate quantitative analysis of heavy metals in soil.