Computing frequency distribution