Operator formulation of centroid dynamics for Bose–Einstein and Fermi–Dirac statistics