Calculating the Spectral Centroid of a Signal
The function you wrote is basically like calculating the center of mass of a body or for that matter the Mean Value of a Distribution.

If you remember from Probability, the Mean is given by:

$$ E \left[ y \right] = \sum_i {y}_{i} p \left( {y}_{i} \right) $$

Now, let's think of the Frequency Function (The DFT) as a probability function.
In order to do so we'll normalize it to have a sum of 1.  

This is done by dividing each element by the sum of elements.
Then just apply the Mean operator to calculate the Mean of this "Distribution":

$$ {C}_{i} = \sum_{k} \underset{{y}_{i}}{\underbrace{k}} \underset{ p \left( {y}_{i} \right ) }{\underbrace{ \frac{{X}_{i} \left( k \right)}{\sum_{k} {X}_{i}
 \left( k \right) } }} $$

The result you'll get is exactly what you have written above.