  We present a newly developed version of BayeSED, a general Bayesian approach
to the spectral energy distribution (SED) fitting of galaxies. The new BayeSED
code has been systematically tested on a mock sample of galaxies. The
comparison between estimated and inputted value of the parameters show that
BayeSED can recover the physical parameters of galaxies reasonably well. We
then applied BayeSED to interpret the SEDs of a large Ks-selected sample of
galaxies in the COSMOS/UltraVISTA field with stellar population synthesis
models. With the new BayeSED code, a Bayesian model comparison of stellar
population synthesis models has been done for the first time. We found that the
model by Bruzual & Charlot (2003), statistically speaking, has larger Bayesian
evidence than the model by Maraston (2005) for the Ks-selected sample. Besides,
while setting the stellar metallicity as a free parameter obviously increases
the Bayesian evidence of both models, varying the IMF has a notable effect only
on the Maraston (2005) model. Meanwhile, the physical parameters estimated with
BayeSED are found to be generally consistent with those obtained with the
popular grid-based FAST code, while the former exhibits more natural
distributions. Based on the estimated physical parameters of galaxies in the
sample, we qualitatively classified the galaxies in the sample into five
populations that may represent galaxies at different evolution stages or in
different environments. We conclude that BayeSED could be a reliable and
powerful tool for investigating the formation and evolution of galaxies from
the rich multi-wavelength observations currently available. A binary version of
MPI parallelized BayeSED code is publicly available at
https://bitbucket.org/hanyk/bayesed.
