How to get the cumulative frequency