How to calculate or approximate the median of a list without storing the list

后端 未结 10 1168
你的背包
你的背包 2020-11-28 22:24

I\'m trying to calculate the median of a set of values, but I don\'t want to store all the values as that could blow memory requirements. Is there a way of calculating or ap

10条回答
  •  一整个雨季
    2020-11-28 22:52

    There is the 'remedian' statistic. It works by first setting up k arrays, each of length b. Data values are fed in to the first array and, when this is full, the median is calculated and stored in the first pos of the next array, after which the first array is re-used. When the second array is full the median of its values is stored in the first pos of the third array, etc. etc. You get the idea :)

    It's simple and pretty robust. The reference is here...

    http://web.ipac.caltech.edu/staff/fmasci/home/astro_refs/Remedian.pdf

    Hope this helps

    Michael

提交回复
热议问题