Building a histogram faster

北城余情 提交于 2019-12-12 00:44:12

问题


I am working with a large dataset that I need to build a histogram of. I feel like my method of just going through the entire list and marking in a second array the frequency is a slow approach. Any suggestions on how to speed the process up?


回答1:


Given that a histogram is a graph containing the counts of all items in each bin, you can't make one without visiting all the items.

However, you can:

  1. Create the histogram as you collect the data. Then it takes no time to generate.

  2. Break up the data into N parts, and work on each part in parallel. When each part is done counting, just sum the results for each bin. (You can also combine this with #1)

  3. Sample the data. In theory, looking at a fraction of your data, you should be able to estimate the rest of it. The Math.



来源:https://stackoverflow.com/questions/18037914/building-a-histogram-faster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!