  An important characterization of electromagnetic and weak transitions in
atomic nuclei are sum rules. We focus on the non-energy-weighted sum rule
(NEWSR), or total strength, and the energy-weighted sum rule (EWSR); the ratio
of the EWSR to the NEWSR is the centroid or average energy of transition
strengths from an nuclear initial state to all allowed final states. These sum
rules can be expressed as expectation values of operators, in the case of the
EWSR a double commutator. While most prior applications of the
double-commutator have been to special cases, we derive general formulas for
matrix elements of both operators in a shell model framework (occupation
space), given the input matrix elements for the nuclear Hamiltonian and for the
transition operator. With these new formulas, we easily evaluate centroids of
transition strength functions, with no need to calculate daughter states. We
apply this simple tool to a number of nuclides, and demonstrate the sum rules
follow smooth secular behavior as a function of initial energy, as well as
compare the electric dipole (E1) sum rule against the famous Thomas-Reiche-Kuhn
version. We also find surprising systematic behaviors for ground state electric
quadrupole (E2) centroids in the $sd$-shell.
