A Divergence Formula for Randomness and Dimension