We calculate the radio-frequency spectrum of a trapped cloud of cold bosonic atoms in an optical lattice. By using random phase and local-density approximations we produce both trap-averaged and spatially resolved spectra, identifying simple features in the spectra that reveal information about both superfluidity and correlations. Our approach is exact in the deep Mott limit and in the dilute superfluid when the hopping rates for the two internal spin states are equal. It contains final state interactions, obeys the Ward identities (and the associated conservation laws), and satisfies the
f-sum rule. Motivated by earlier work by Sun, Lannert, and Vishveshwara [Phys. Rev. A 79, 043422 (2009)], we also discuss the features that arise in a spin-dependent optical lattice.
We provide a numerical method to calculate comprehensively the microwave and the laser spectra of ultracold bosonic atoms in optical lattices at finite temperatures. Our formulation is built up with the sum rules, up to the second order, derived from the general principle of spectroscopy. The sum rule approach allows us to discuss the physical origins of a spectral peak shift and also a peak broadening. We find that a spectral broadening of superfluid atoms can be determined from number fluctuations of atoms, while that of normal-state atoms is mainly attributed to quantum fluctuations resulting from hopping of atoms. To calculate spectra at finite temperatures, based on the sum rule approach, we provide a two-mode approximation assuming that spectra of the superfluid and normal state atoms can be calculated separately. Our method can properly deal with multipeak structures of spectra resulting from thermal fluctuations and also coexisting of the superfluid and the normal states. By combining the two-mode approximation with a finite temperature Gutzwiller approximation, we calculate spectra at finite temperatures by considering realistic systems, and the calculated spectra show nice agreements with those in experiments.