  By applying a Bayesian model-to-data analysis, we estimate the temperature
and momentum dependence of the heavy quark diffusion coefficient in an improved
Langevin framework. The posterior range of the diffusion coefficient is
obtained by performing a Markov chain Monte Carlo random walk and calibrating
on the experimental data of $D$-meson $R_{\mathrm{AA}}$ and $v_2$ in three
different collision systems at RHIC and the LHC: AuAu collisions at 200 GeV,
PbPb collisions at 2.76 and 5.02 TeV. The spatial diffusion coefficient is
found to be consistent with lattice QCD calculations and comparable with other
models' estimation. We demonstrate the capability of our improved Langevin
model to simultaneously describe the $R_{\mathrm{AA}}$ and $v_2$ at both RHIC
and the LHC energies, as well as the higher order flow coefficient such as
$D$-meson $v_3$. We show that by applying a Bayesian analysis, we are able to
quantitatively and systematically study the heavy flavor dynamics in heavy-ion
collisions.
