Compute statistics - Separate pass to compute statistics for each category