Added a function to calculate frequency distributions to correct the rounding up errors.
\approve @ds @tara